[M3devel] Static chains
Rodney M. Bates
rodney.bates at wichita.edu
Tue Jan 15 02:56:05 CET 2008
Modula-3 prevents the dangling environment problem with a rule
that, while a nested procedure can indeed be passed as a parameter,
it can not be assigned to a variable. Only a top-level procedure
value can be assigned to a variable.
In general, this has to be checked at runtime, at the time of an
assignment. The compilers all do this by making the RT representation
of a procedure value explicitly denote whether it is nested or top-level.
hendrik at topoi.pooq.com wrote:
> On Mon, Jan 14, 2008 at 10:47:28AM -0500, Tony Hosking wrote:
>
>>Rodney,
>>
>>I just realised that the static chains variables are *not* always
>>being set up for nested function internal use. i.e., callers will
>>pass them, but nested functions that don't explicitly use them will
>>not have a static chain. Is this something essential for you? Why
>>would you need a static chain from within a nested function that
>>doesn't use any outer scope variables? Since it doesn't use any
>>outer scope variables they cannot affect its execution, so debugging
>>the value of those variables seems unnecessary. This is the default
>>behavior of gcc for static chains.
>
>
> And having them could break languages where it's possible to export
> procedures to places where their nonlocal procedures are still in
> existence but the intermediate lexical levels which they don't use are
> not. (Algol 68 is a case in point)
>
> -- hendrik
>
>
>>-- Tony
>>
>
>
--
-------------------------------------------------------------
Rodney M. Bates, retired assistant professor
Dept. of Computer Science, Wichita State University
Wichita, KS 67260-0083
316-978-3922
rodney.bates at wichita.edu
More information about the M3devel
mailing list