On Fri, Dec 5, 2008 at 12:39 PM, Maciej Stachowiak <[EMAIL PROTECTED]> 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?
Based on the lambda and return-to-label strawmen, It's an error. Dave presents a desugaring of function to lambda, where each function body is given a label at the bottom: lambda(x0,...,xn,...$rest) { let $THIS = thisRegister; let arguments = makeAlias([[lambda() x1, lambda($x1) x1 = $x1], ..., [lambda() xn, lambda($xn) xn = $xn]], $rest); $RETURN: { Body; void 0 } } 'return e' without a label desugars to: return : $RETURN e But, from the return-to-label strawman: "The dynamic return point associated with the label must still be live when the return statement is invoked; otherwise it is a dynamic error, i.e., an exception is raised." A label is an escape continuation. Once control has returned past the point where the continuation was captured, it's dead, and it can't be resumed. -Jon _______________________________________________ Es-discuss mailing list Es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss