[fpc-devel] Re: [fpc-announce] Feature announcement: Type helpers
Paul Ishenin
paul.ishenin at gmail.com
Fri Feb 8 15:21:45 CET 2013
08.02.13, 21:52, Gerhard Scholz wrote:
> Maybe I didn't understand the syntax correctly: I didn't see how to get
> the value inside the method?
By accessing Self
> example:
>
> type
> TLongIntHelper = type helper for LongInt
> class procedure ShowValue; static;
> end;
>
> class procedure TLongIntHelper.Test;
> begin
> Writeln('Value=',self);
> end;
Replace your static class procedure with regular method:
procecure TLongIntHelper.Test;
begin
WriteLn(Self);
end;
Class static method is only needed if you are going to call it for the
type declaration itself like: LongInt.PrintSize:
class procedure TLongIntHelper.PrintSize;
begin
WriteLn(SizeOf(LongInt));
end;
static methods don't have a magic Self variable.
In any case I suggest to look for test which had been commited together
with Sven patch.
Best regards,
Paul Ishenin
More information about the fpc-devel
mailing list