[fpc-pascal] Type helper for array

Vojtěch Čihák vojtech.cihak at atlas.cz
Thu Jun 9 17:57:32 CEST 2016


Hello,
 
I've got following declaration:
...
{$modeswitch typehelpers}
 
interface
 
uses
  Classes, SysUtils;
 
type
  TBuffer = array of Single;
 
  { TBufferHelper }
  TBufferHelper = type helper for TBuffer
    procedure Clear;
  end;
...
var aBuffer: TBuffer;
...
And I can do:
aBuffer[3]:=5;
aBuffer.Clear;
 
Is it possible to do this without helper? Since it's IMO silly to have helper in the same unit as the original declaration. Helpers are usually used where extending of the original type is not possible, aren't they?
 
Thanks,  V.



More information about the fpc-pascal mailing list