proper tail calls

Jon Zeppieri jaz at
Mon Jan 21 10:28:27 PST 2008

On 1/21/08, Igor Bukanov <igor at> wrote:
> let f2;
> function f(a)
> {
>     f2 = function() { return a; }
>     goto return g();
> }
> function g() {f2 = null; ... }
> Here in f "return g()" is in tail position yet the frame of f can not
> be eliminated completely since it is referenced through a global
> variable.

I don't understand your claim.  You're saying that the "frame of f"
is "referenced through a global variable"?  Clearly, f2 is the global
variable, you're referring to.  f2 may be bound to a function value
that closes over a, which is part of f's activation frame -- or, more
specifically, part of f's closure environment.  But how would this
prevent the call to g from being a tail call?  Are you assuming that a
must be on the stack?

More information about the Es4-discuss mailing list