|procedures and environments debray@CS.Arizona.EDU (1999-11-04)|
|Re: procedures and environments firstname.lastname@example.org (1999-11-05)|
|Re: procedures and environments email@example.com (Max Hailperin) (1999-11-05)|
|Re: procedures and environments firstname.lastname@example.org (David L Moore) (1999-11-05)|
|Re: procedures and environments email@example.com (1999-11-05)|
|Re: procedures and environments firstname.lastname@example.org (1999-11-09)|
|Re: procedures and environments email@example.com (1999-11-09)|
|From:||Max Hailperin <firstname.lastname@example.org>|
|Date:||5 Nov 1999 01:33:05 -0500|
|Organization:||Gustavus Adolphus College|
debray@CS.Arizona.EDU (Saumya K. Debray) writes:
...In other words, a call would
> transfer control to the callee, which could either allocate an
> environment, or---if it chose to not allocate an environment for
> itself---execute in the caller's environment.
> [Seems to me it'd happen sort of automagically if a routine had no
> variables of its own but instead used only variables from the up-level
> routine. You'd skip allocating a frame pointer and use the caller's
> frame. I agree that calling sequences without separate frame pointers
> make this pretty yucky. -John]
It seems to me a slight clarification is needed here -- execution in
the caller's environment would only be an automagic consequence of
having no local variables if the procedure were dynamically scoped.
With lexcial scoping, it would be executing in its parent's
environment, which might not be the same as its caller's environment.
So in a dynamically scoped language (for example, ancient versions of
lisp) Debray's question would need no more answer. But the
interesting interpretation of Debray's question is whether anyone has
a language that is normally lexically scoped, but in which individual
procedures can be marked as dynamically scoped. I know of no such
language. The only linguistic devices I've seen for mixing lexical
and dynamic scoping in a single language involve marking individual
*variables* (or bindings) as to how they should be scoped, rather than
procedures. What we really want for Debray's problem, as I understand
it, is a situation where if the nesting of procedures were as follows
and p3 and p5 both have local variables x, and p2 is marked as a
special dynamically-scoped procedure, then if p3 calls p2, p2 has
access to p3's x, but if p3 calls p5 which in turn calls p4, then p4
has access to p3's x rather than p5's.
Associate Professor of Computer Science
Gustavus Adolphus College
800 W. College Ave.
St. Peter, MN 56082
[Well, it could also be an automagic consequence of having no local
variables and only referring to variables in the immediate caller's
scope, e.g., code like most C code. -John]
Return to the
Search the comp.compilers archives again.