[gclist] Re: gclist-digest V3 #36

Robert A Duff bobduff@world.std.com
Tue, 27 Jul 1999 09:33:18 -0400

> Standard Pascal used a similar technique for procedure parameters.
> Procedure parameters could be passed down to subroutines, but
> subroutines could not return procedure results, and you couldn't
> have variables or fields which were procedure references.
> The only thing you could do with a procedure parameter was to
> call it, or to pass it down as an argument to another procedure.
> This ensured that Pascal compilers could allocate closures
> (references to nested procedures) on the stack rather than on the heap.
> I think Modula-2 also used the same technique.

No, Modula-2 is different from Pascal here.  In Modula-2, you can assign
pointers-to-procedures into global variables, and return them from
functions.  But you are not allowed to take the address of a nested
procedure, so the compiler can still do the usual stack allocation.  Ie
Modula-2 has the same power as C in this respect; C doesn't even *have*
nested functions.

- Bob