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

Olle Raab automagi at algonet.se
Mon Dec 1 18:18:41 CET 2003


03-11-30 10.36, skrev Jonas Maebe följande:

> 
> On 30-nov-03, at 02:29, Pedro Lopez-Cabanillas wrote:
> 
>> Of course, if the compiler doesn't support this feature, because the
>> internal
>> handling of function calls, a compiler error message is better than a
>> program
>> crash.
> 
> The problem is that some iterator-implementations do (and only) support
> local functions/procedures. The collections in TP's (and as such also
> FPC's) objects.pas are an example. They include special code for that
> support, however. So always giving an error is going to give a lot of
> false errors for people coming from TP/BP.
> 
>> But I was talking about Pascal language conventions. Instead of my code
>> snippet, you can refer to the document "Extended Pascal", ISO-10206,
>> chapter
>> 6.11.6, examples 6-9. It's available here (among other places):
>> http://www.pascal-central.com/standards.html
>> 
>> And GPC supports this feature, see:
>> http://www.gnu-pascal.de/demos/iteratordemo.pas
> 
> That's because GPC supports standard/extended Pascal, we don't. To
> implement this, I think a procedure variable must always be a
> pointer+it's frame pointer (nil if it's not a nested procedure), a bit
> like procedure of object.

This is correct, in some Apple docs this pointer was called the "static
link".

It's also supported in mac pascal dialects. It would be nice if we could
support it, it is one of the strength with pascal to be able to do such
things, e g supporting a local compare funciton to a generic sort procedure,
IMHO. Its a nice feature to beat C fans with.

Olle





More information about the fpc-devel mailing list