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

> On Fri, Jul 12, 2013 at 6:45 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
> >
> >
> > Given:
> >
> >   function foo(){ return 1; }
> >
> >
> > This is a valid function call:
> >
> >   foo
> >   ()
> >
> >   // 1;
> >
> > But this is valid, too (though, not a function call):
> >
> >   foo  <-- identifier
> >   {} <-- empty block
> >
> >   // function foo() { return 1; }
> >
>
> This construction
>
>   foo {};
>
> is an equivalent of:
>
>   foo({});
>
> but not
>
>   foo();
>


Right, I get that... but what I'm telling you is that your proposal doesn't
work:

  foo {}

Same as

  foo({})


So, that means:

foo
{}

should be the same as

foo
({})

...Because this is a valid function call.

But it's not the same and cannot be defined as the same, because ASI put a
semi colon at the end of |foo| and {} is a valid empty block. Changing this
would surely be web breaking.


Rick










> To call function with empty param list you still need empty '('')'
> brackets.
>
> >
> > Also, I could be wrong, but wouldn't there need to be a way to
> disambiguate
> > UnaryExpression?
> >
> >   typeof foo { one: 1, two: 2 }
> >
> > Maybe this is not an issue, or easily dealt with?
>
> This is not an issue. Parsed exactly the same as:
>  typeof foo({ one: 1, two: 2 })
>


Right, but again:

  function foo() {return 1;}

  typeof foo
  ({})

  "number"

...Because this is the same as

  typeof foo({})

So you need a [no LineTerminator here], which unnecessarily complicates:

CallExpression Arguments
CallExpression[no LineTerminator here]ObjectLiteral


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

Reply via email to