return when desugaring to closures
waldemar at google.com
Mon Oct 13 17:00:12 PDT 2008
Mark S. Miller wrote:
> On Sat, Oct 11, 2008 at 9:11 AM, Peter Michaux <petermichaux at gmail.com> wrote:
>> I think it would be ok to have only unnamed lambdas. (It would be ok
>> to have named lambdas too.)
> I think we should not introduce named lambdas because then we'd need
> to decide whether the scoping of a lambda name works the same as the
> scoping of a function name. Do we really want to reproduce the
> following confusions:
> * Distinction between named function expressions vs named function declarations?
> * The name of a name function expression is only in scope within the
> function, whereas the name of a named function declaration is in
> (letrec) scope in the containing block.
> * Because these look the same, a named function expression cannot be
> used naked as the start of an expression statement. It must wear
> protective parentheses.
> * For consistency, an anonymous function expression also cannot be
> used as a naked as the start of an expression statement.
> If lambdas had optional names, we would either need to reproduce the
> above confusions or deviate from them. Either choice is terribly
The main benefit of named lambdas is intelligible stack traces in a debugger. What would you replace them with? In a lot of places there is no other good place to stick a name onto; I don't want to assign a lambda to a variable just so I can name it.
More information about the Es-discuss