(Almost) everything is expression
Brendan Eich
brendan at mozilla.com
Fri Nov 11 08:53:41 PST 2011
On Nov 11, 2011, at 2:52 AM, Axel Rauschmayer wrote:
>> which I thought could be turned into:
>> -----
>> var C = {
>> let something;
>>
>> // |this| is the global object
>> // ...
>> }
>> -----
>>
>> But it does not have a return value and as noted in your second message, there seems to be an ambiguity with object initializers (not only visual but formal).
>> The 'do expressions' solution sounds like a good idea, but visually reminds of a do-while loop.
>>
>> I don't really have a better proposition yet, but i'm looking forward to seeing any solution that will allow to replace all "(function(global){...})(this);"
>
>
>
> IIRC: Block lambdas.
>
> var C = {|| // note the double pipe
> let something;
>
> // |this| is the global object
> // ...
>
> return something;
That would attempt to return from the enclosing function or be an early error if there is no enclosing function.
Principle of equivalence, e ==== {|| e}(), applies.
/be
More information about the es-discuss
mailing list