[fpc-devel] FPC 2.2.3 i386-darwin snapshot
dmitry boyarintsev
skalogryz.lists at gmail.com
Sun Mar 8 19:10:50 CET 2009
yeah, i've seen description of 'static' usage at the mailing list
(subj: crashing _self parameter)
This is a new feature for FPC, right? (catching up with new delphi syntax?)
a few questions about that:
1) 'static' methods are regular procedures/functions, but bound to a
class rather than a unit?
2) it's possible to pass 'static'-methods as procedure variables?
TMyObject = class
class procedure MyMethod; static;
end;
TProc = procedure;
procedure MyProc;
begin
...
end;
procedure DoSomething(CallBack: TProc);
begin
Callback(); // call here
end;
begin
DoSomething(@MyProc); // it's possible
DoSomething(@TMyObject.MyMethod); //it's possible either, with no
extra type casting.
end.
3) only class methods can be 'static'? it's impossible to declare a
method like:
TMyObject = class
procedure MyMethod; static;
end;
4) no Self parameter is available inside the 'static' method. (since
it's regular procuder or function)
5) 'static' keyword is used only if compiler -St switch specified?
6) how are they actually named? because there're two kind of static
methods available:
TMyObject = class
class function MyClassProc; // static class method
class function MyClassVirtualProc; virtual; // virtual class
method. can be overriden.
class function MyClassVirtualProc; dynamic; // dynamic class
method. can be overriden too
class function MyClassProc; static; // "static" class method?
end;
Thanks,
Dmitry
More information about the fpc-devel
mailing list