Allen's lambda syntax proposal

David-Sarah Hopwood david.hopwood at industrial-designers.co.uk
Fri Dec 5 18:43:23 PST 2008


Maciej Stachowiak wrote:
> What exactly does return from a lambda mean? Let's say I do this:
> 
> function F(x) { return lambda(n) { return x + n; } }
> function G(h) { return h(1) +1; }
> var H = F(1);
> G(H);
> 
> What is the value of the last expression and why?

The lambda would return from F (specifically, from the activation of F
in which the lambda was created), but since that activation of F has
already returned when the lambda is called, this is a dynamic error --
presumably, resulting in an exception.

What that example doesn't show it is whether the exception is thrown
only when the offending 'return' statement is executed, or when a
a lambda that *could* execute an offending return is entered.

Also note that this example could be affected by the resolution of
the "leakage" issue, if we decide for example that the syntax
'lambda(n) { return x + n; }' returns from the lambda rather than
the enclosing function (which it could do without necessarily
violating the Tennent Correspondence rationale for lambdas, as long
as there is another syntax that doesn't bind 'return').

-- 
David-Sarah Hopwood


More information about the Es-discuss mailing list