return when desugaring to closures
waldemar at google.com
Tue Oct 21 15:42:25 PDT 2008
Brendan Eich wrote:
> Followup to discuss some open issues from the thread, evident in the
> message cited below:
> 1. Unifying var scope and let scope at top level of a function could be
> done, with tolerable restrictions: given let x at top level in a
> function body, existence of formal parameter x, and redeclaration of let
> x by top-level var x, are static errors.
> 2. Unifying var scope and let scope at top level in global code cannot
> work since var x creates a DontDelete property of the global object if
> no property x exists, else redeclares an existing property x having
> arbitrary attributes.
> We could make let at top level in global code an error. Making such a
> let bind in an implicit block seems bad because inconsistent with 1,
> because implicit, and because it's more complicated to implement and
> specify than making global top-level let an error.
> Any pragma of the "use lexical scope" kind:
> would remove this restriction.
Presumably the same rationale applies to const and this means that we can't use const at the top level either, not even in ES3.1?
What does ES3.1 do if you have both const x and var x at the top level?
More information about the Es-discuss