[Lazarus] Method in record type, is possible?

Sven Barth pascaldragon at googlemail.com
Wed Mar 16 09:46:54 CET 2011


Am 16.03.2011 08:58, schrieb Graeme Geldenhuys:
> Op 2011-03-16 04:24, silvioprog het geskryf:
>>
>> This is possible in Lazarus/FPC?:
>>
>> type
>> TFoo = record
>> Value: string;
>> function AsBoolean: Boolean;
>> end;
>>
>> function TFoo.AsBoolean: Boolean;
>> begin
>> Result := StrToBoolDef(Value, False);
>> end;
>>
>> In Delphi:
>>
>> http://edn.embarcadero.com/article/34324
>
> That is the stupidest feature I have seen in Delphi. They simply
> rehashed something that existed since pre-Delphi v1, and then call it
> something "new". What you are looking for is the age old Object structure.
>
> TFoo = object
> Value: string;
> function AsBoolean: Boolean;
> end;
>
>
> And yes, FPC supports the Object structure. ;)

And since beginning of this year FPC also supports the "advanced record" 
(you need a trunk version of course).

Regards,
Sven




More information about the Lazarus mailing list