On Nov 11, 2011, at 9:13 AM, David Herman wrote: > On Nov 11, 2011, at 8:19 AM, Mark S. Miller wrote: > >> On Fri, Nov 11, 2011 at 7:40 AM, gaz Heyes <gazhe...@gmail.com> wrote: >> On 11 November 2011 15:33, Mark S. Miller <erig...@google.com> wrote: >> let a = ({ >> >> print('doing stuff'); >> 100; >> }); >> >> How do you know the difference between a blank block statement and a object >> literal? Surely it becomes an expression once an assignment occurs anyway. >> >> Doh! Sorry, I completely mis-thought that. Nevermind. > > Your idea of mandatory parens is still valid (if, IMO, a bit unsatisfyingly > verbose) for most statement forms. It's only the block-statement-expression > that doesn't work. Hence my do-expressions: > > http://wiki.ecmascript.org/doku.php?id=strawman:do_expressions > > or Brendan's subtly-disambiguated-block-statement-expressions: > > http://wiki.ecmascript.org/doku.php?id=strawman:block_vs_object_literal > > If Brendan's idea can be made to work, and it's not too confusing, I'm pretty > sure I'd prefer it over do-expressions.
I think you''d be making a mistake to go in that direction. do-expression is a very good solution that fits very well into the language and does not introduce any new readability ambiguities (coining a phrase, a readability ambiguity is a construct that is not formally ambiguous according to the grammar but which will require mental effort by a human reader to appropriate classify). > You could simply write: > > let a = { > print('doing stuff'); > 100 > }; > > How gorgeous is that? not very... when I see a = { I immediate have to start thinking, is this think that follows the =? Is it block expression? is it an object literal? is it a block lambda? but if I see any of: let a = do {... let a = {|| ... let a = { ... I immediately know what follows. That is gorgeous... > > But I suspect as we work on evolving the syntax of object literals, it'll get > harder to keep them disambiguated. For example, is this: we're already there ... > > let a = { > foo(x) > { > alert(x) > } > } > > ...equivalent to this? > > let a = { > foo: function(x) > { > alert(x); > } > }; > > ...or this? > > let a = { > foo(x); > { > alert(x); > } > }; > > So I just don't know if it's feasible. And being technically feasible does not make it desirable. Just remember the phrase: "readability ambiguity" Allen
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss