[fpc-devel]Nested function as argument for TList.Sort

Pedro Lopez-Cabanillas plcl at telefonica.net
Thu Nov 27 21:11:21 CET 2003


Peter Vreman wrote:
[...]
> > This is bad coding imho and works in Delphi only "by accident" because
> > Delphi uses register calling conventions. Or are I'am wrong and sort
> > expects a local procedure?
>
> The compiler should give an error. It is bad coding and only a
> "undocumented feature" of delphi register calling that makes it working.
> Because there is no full description of the register calling in delphi,
> like how does it insert the self,parameter return or parent framepointer
> parameters.

I don't fully agree with both comments. Why is it bad code? Is this code 
violating some rule about scope, or any other rule or Pascal language 
convention? If not, the compiler is right here, eating this code without a 
single warning.

OTOH, if the construct is not allowed and the program crashes under both FPC 
and old releases of Delphi compilers (this is not true anymore, because at 
least under Kylix3 this is perfectly legal and runs fine), If this construct 
is not supported by FPC, it should be stated at some point in the 
documentation. Perhaps a line about it on the FCL documentation, inside the 
TList.Sort description, and the Reference guide, section 3.5 - Procedural 
types.

BTW, the same issue about TList.Sort was discussed some time ago in Borland's 
forums, see:
http://groups.google.com/groups?&selm=6c4ter%24j1c4%40forums.borland.com

It is a comment from a Borland's developer, justifying why this code does not 
work under Delphi 3, and giving some details about internals. I guess that it 
is not an accident if it works under newer Delphi releases. The main point is 
that he apologizes about that ;-)

I hope that you don't get angry with me because my comments, I really like FPC 
and want it being my main developing tool. Thank you very much to all the FPC 
team.

Regards,
Pedro

-- 
ALSA Library Bindings for Pascal
http://alsapas.alturl.com





More information about the fpc-devel mailing list