[fpc-devel] Local procedures as procedural parameter

Jonas Maebe jonas at zeus.ugent.be
Mon Mar 14 11:40:07 CET 2005

On 14 mrt 2005, at 11:11, olle.r at automagika.se wrote:

>> I would only see the use of being able to pass a local function as a
>> callback
>> if the called function can be used for both local and global callback
>> procedures.
> It can. When a global proc is passed, the static link is set to nil.

That is not possible, because the static link parameter is currently 
passed as an implicit hidden *first* parameter. If you start passing an 
extra first parameter with the value "nil" to procedures, you'll get 
all sorts of strange effects.

The PPC ABI actually prescribes that the static link parameter should 
always be passed in r11 (which can never be used for any other 
parameter, since regular parameters stop at r10), so then this works. 
However, in that respect we don't follow the PPC ABI, and it would also 
break on other processors so that's not an option.

The only possibility I see for this is to make the hidden static link 
parameter the last instead of the first parameter.


More information about the fpc-devel mailing list