On Tue, Sep 2, 2008 at 2:16 PM, Lex Spoon <[EMAIL PROTECTED]> wrote:
> On Sun, Aug 24, 2008 at 3:17 AM, Brendan Eich <[EMAIL PROTECTED]> wrote:
>> First, let's settle the hash over whether any desugaring without
>> extensions such as return-to-label, reformed lexical scope, tamed
>> this, banished arguments, etc. etc., trumps adding a new binding
>> form, to wit: let as block scoped var.
>
> With no extensions, it is true, return would end up returning from a
> different method under the proposed rewrite.  Likewise, this and
> arguments would cause trouble.  Possibly break and continue would,
> depending on what their precise semantics are.
>

Wouldn't any Completion Type cause problems?

(function() {
  throw Error("help.");
})();

?

Wouldn't the caller, stack, et c, be all messed up?

> However, they work under some specific extensions that appear to
> benefit JavaScript anyway.  I suspect that most languages with both
> return expressions and nested functions will eventually want a way to
> return from other than the innermost function.  More generally, it
> would be really nice if programmers could safely add a nested function
> without losing access to important things from their surrounding
> scope.  That goes not just for return, but also arguments, this,
> break, and continue.

Those are not lost if you store them in a variable in the containing scope.

It wouldn't make sense to have - return: outerFunction - because the
outer function might not have been the caller. In fact, it probably
won't be in the majority of cases.

>  It's an orthoganality problem.  With
> JavaScript's current limited return expression, programmers have
> trouble when they try to use both function nesting and return at the
> same time.  Using one feature makes it harder to use the other.
>

I've never wanted to do that; to make the inner function make the
outer function return.

>
> Finally, there was a little bit of question about what the semantics
> would be.  Let me go into just a little more detail.  The idea is that
> instead of just "return foo", you could also put a label on the
> return.

What would you use that for?

>
> -Lex
_______________________________________________
Es-discuss mailing list
Es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to