On Fri, Jul 12, 2013 at 2:08 PM, Andrew Fedoniouk <[email protected]
> wrote:

> On Fri, Jul 12, 2013 at 7:02 AM, Rick Waldron <[email protected]>
> wrote:
> >
> >
> >
> > On Fri, Jul 12, 2013 at 12:22 AM, Andrew Fedoniouk
> > <[email protected]> wrote:
> >>
> >> Quite often I see  constructions like this:
> >>
> >> foo({one:1,two:2});
> >>
> >> so call of function with single parameter - object literal.
> >> Idiom named "Poor man named arguments passing"
> >>
> >> Idea is to extend existing JS/ES syntax calls to support
> >> simple form of the call above:
> >>
> >> foo {one:1,two:2 };
> >>
> >> Semi-formally that syntax looks like:
> >>
> >> function-call:
> >>    <name-token> '(' <parameter-list> ')' // existing form
> >>    <name-token> <object-literal> // proposal
> >
> >
> > Existing grammar:
> >
> >
> >   CallExpression Arguments
> >
> >   Arguments :
> >     ( )
> >     ( ArgumentList )
> >
> >
> > To add ObjectLiteral, at very least the grammar would need to have a
> > NoLineTerminator between CallExpression and Arguments, which breaks
> extant
> > code.
>
> Yes, NoLineTerminator is required for non-strict mode (that ugly
> semicolon elision
> strikes again)
>
> Even in non-strict mode this code:
>
>   function foo(obj) { return 1; }
>
>   var c = foo { one:1 };
>
> produces parsing error before the '{' - "semicolon required".
>

Of course it does, but again, you're ignoring my point about ASI.
Invocation parens (and arguments list) are allowed to be on the a following
line:

  function foo(value) { return value; }

  foo




  ("hi!")

// "hi!";


And again, the opening and closing curly brace synatx that you think is an
ObjectLiteral becomes a valid Block on the next line (because invocation
parens and argument lists CAN be on the next line):

  function foo(obj) { return 1; }

  var c = foo
  { one:1 }; <-- valid block, containing a LabelStatement
  // 1

  c;
  // function foo(obj) { return 1; }



>
> The same kind of error is in this case too:
>
>   function foo(p1,p2) { return 1; }
>
>   var c = foo 1,2;
>

Still the same reason I've said over several responses.

  function foo(p1,p2) { return 1; }

  var c = foo
  1,2;

  // 2
  c;
  // function foo(obj) { return 1; }




> So that syntax change will be backward compatible - it will
> not change semantic of existing valid code.
>

Contrary to the evidence I've provided several times in several messages?

Rick
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to