On Wed, May 30, 2012 at 8:40 PM, Allen Wirfs-Brock <[email protected]>wrote:
>
> On May 30, 2012, at 5:14 PM, Brendan Eich wrote:
>
> Allen Wirfs-Brock wrote:
>
> I now could be quite happy with the paren based cascade idea that Brendan
> suggested last night. I'm surprised that no one has commented on the bnf I
> provided in a subsequent message.
>
>
> Grammar is a detail at this point. The objection to parens is reasonable
> enough: they look bad when split across multiple lines:
>
>
> obj.(
> deep.(
> deeper: val;
> deeper2: val2
> )
> )
>
>
> They look different, but it's not clear to me that it looks bad. I would
> use = instead of : because we are really just factoring expressions and =
> is the operator that we are dealing with.
>
> There is a simple story for how:
>
> obj.foo=val;
> obj.bar=val2;
>
> factors into:
>
> obj.(
> foo=val;
> bar=val
> );
> or
> obj.(foo=val, bar=val2);
>
Parens with comma separation might be too visually similar to this:
function obj(a, b) { console.log(a, b); }
obj(foo="1", bar="2")
> 1 2
>
> changing the = to : seems arbitrarily different hurts the simple story.
> No where else in the language does : mean assignment.
>
> (assume everything doesn't fit on one line).
>
> Schemers might style this thus:
>
> obj.(deep.(deeper: val;
> deeper2: val2))
>
> but that looks bad too -- too ragged-left with arbitrary indentation and
> )))) pile-ups at the end.
>
> Braces look right because they follow K&R style, which as Crock points out
> wins in JS because of restricted productions, specifically
>
>
> K&S style can be applied whether you use () or {} so I don't see who that
> is relevant.
>
>
> return {
> obj: literal,
> here: right
> };
>
> So,
>
> obj.{
> deep.{
> deeper: val;
> deeper2: val2
> }
> }
>
> The big issue is the
> obj .
> {
> deeper: val;
> deeper2: val
> }
>
>
I absolutely agree, but change it to = and it becomes distinguishable
(opinion, of course ;D )
obj.
{
deeper = "1";
deeper = "2"
}
Rick
> look exactly like an object literal (except for the ; which is too small
> of a difference to matter) but has different semantics.
>
> Allen
>
> _______________________________________________
> es-discuss mailing list
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
>
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss