return when desugaring to closures

Peter Michaux petermichaux at
Thu Aug 21 19:26:33 PDT 2008

On Thu, Aug 21, 2008 at 7:08 PM, Brendan Eich <brendan at> wrote:
> On Aug 21, 2008, at 7:04 PM, Peter Michaux wrote:
>> On Thu, Aug 21, 2008 at 6:34 PM, Brendan Eich <brendan at> wrote:
>> [snip]
>>> The destructuring pattern here is an array, but objects work too:
>>> js> let {length: len} = foo()
>> The above has always instinctively looked to me like the variable
>> "length" is being assigned the value of the "len" property of the
>> object returned by foo. That is the way an object literal works: the
>> right value is assigned to the left property.
> Probably not instinct (no survival advantage ;-); possibly lack of
> familiarity with the new form in context. Try using it in more realistic
> code for a few days (especially the shorthand form) and ping me if it still
> reads like an object initialiser.

It works in practice as context of syntax sometime matters.

This is definitely an example of the same syntax having semantically
different meaning (actually opposite meanings) which was an objection
to the use of return in an let statement if a let statement desugars
to a function-expression call.


More information about the Es-discuss mailing list