(Almost) everything is expression

David Herman dherman at mozilla.com
Fri Nov 11 10:05:35 PST 2011

On Nov 11, 2011, at 9:50 AM, Allen Wirfs-Brock wrote:

> do-expression is a very good solution

Why thank you! ;-)

>> How gorgeous is that?
> not very...
> but if I see any of:
>   let a = do {...
>   let a = {|| ...
>   let a  = { ... 
> I immediately know what follows. That is gorgeous...

I'm not sure I buy that `let x = do { f(); 12 }` is *prettier* than `let x = { f(); 12 }` but I do agree that it's less subtle, given the existence of object literals. And `do` is as short a keyword as you can get in JS, so it's a pretty minimal amount of extra noise.

>> So I just don't know if it's feasible.
> And being technically feasible does not make it desirable.

Of course. I didn't just mean "technically feasible," I meant I don't know if it's feasible from a design perspective.

> Just remember the phrase: "readability ambiguity"

Fair enough. Personally, I think there are situations where a disambiguation that's *technically* subtle can actually be totally intuitive to the human eye and doesn't cause readability problems in practice. But I agree with you that this is not likely one of those cases. There's just too much overlap between what can go inside an object literal and what can go inside block statements.


More information about the es-discuss mailing list