On 11.11.2011 14:52, 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;
}


With a single expression, you don’t even have to return:

var C = {||   // note the double pipe
    foo()
}


This contradicts TCP though. E.g. Ruby supports it and there we can't `return` from blocks, since block wrapping should not be treated as a function.

OTOH, as I noted in the initial letter, it can be convenient to return from the middle of such a block with exactly `return` statement. But, it's again contradicts TCP, and `return` should exit exactly execution context, but not just a block. Exactly for this it's used in Ruby, when begin inside a function you may exit directly from the function using `return` from the block passed to a higher-order function, e.g. `each` or arrays.

Besides, if to accept this Ruby's blocks, then in common case -- e.g. as shorted notation for functional arguments.

Dmitry.
_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to