[fpc-pascal] Class procedural type

Ewald ewald at yellowcouch.org
Tue Dec 18 20:10:41 CET 2012


Once upon a time, on 12/18/2012 06:42 AM to be precise, Sven Barth said:
>
> Am 17.12.2012 22:27 schrieb "Ewald" <ewald at yellowcouch.org
> <mailto:ewald at yellowcouch.org>>:
> >
> > It should not contain this hidden parameter? In that case the above
> code (with the intermediate pointer cast) would prove correct? (of
> course it is no cross platform solution or anything, but that is
> besides the matter now)
>
> It would be a cross plattform solution, because the method pointer
> will just be a Pointer insteat of a TMethod record.
>
Indeed, my thoughts got a bit mixed up at one point. This would indeed
be cross platform.

> > > If you want to use the above you need to declare your method as
> "static;". In that case a method will behave the same as a normal
> procedure variable, but if you want to change e.g. class properties or
> class variables of the class the method belongs to, you must use the
> class name (e.g. TMyClass.MyProperty) to access it.
> >
> > So if I get you right, the use of `static` after a method make the
> hidden class type parameter disappear, but also mandates use of the
> class name every time I want to use the class' [static fields / class
> properties / class methods]?
> >
>
> Not quite, see Paul's mail. Sorry for the confusion :)
>
> > Suppose TTestClass contains `AField: Integer; static;`, then the
> following would be right if I understand you correctly?
> >
> > Class Procedure TTestClass.AMethod; static;  // I don't know if
> `static` should be in the implementation as well, but I'll soon figure
> out :-)
>
> It's enough to have it in the declaration.
>

Alright. Seems like you helped me fix this issue. Thanks for your time
(as well as Paul's of course)!

-- 
Ewald

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.freepascal.org/pipermail/fpc-pascal/attachments/20121218/6300c60f/attachment.html>


More information about the fpc-pascal mailing list