> On Mar 22, 2022, at 4:53 PM, Rhialto <rhia...@falu.nl> wrote:
> 
> On Tue 22 Mar 2022 at 17:46:49 +0000, Koning, Paul wrote:
>> I don't believe ALGOL implementations needed executable stacks to implement 
>> nested functions, for example.
> 
> No, a common way to do it (as in the Dragon Book), if I recall
> correctly, the address of the function combined with a stack frame
> pointer. And nested functions keep a static link to the lexically
> enclosing scope, or alternatively a "display". I'm not sure if A68 would
> automatically move locals from surrounding scopes into the heap (like in
> a closure); it could well be that there was run-time checking instead if
> you tried to use a function pointer outside of the scope of any of the
> locals it used.
> 
> But these sorts of strategies require bigger function pointers, which
> you basically can't do in C.

Can't you?  Does C require function pointers to have the same type, or 
compatible structure, as data pointers?

If it does, that would mean you can't get a pointer to a nested function, which 
is no different from the C++ rule that you can't get a (plain function) pointer 
to a member function.

        paul


Reply via email to