Rick Waldron (2013-07-12T13:45:56.000Z)
On Fri, Jul 12, 2013 at 12:22 AM, Andrew Fedoniouk <
news at terrainformatica.com> 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; }


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 syntax extension will not break correct pre-ES6 code
> as far as I can tell. But I am not sure about new ES6 arrivals.
>
> In fact we can add even more generic form of function call:
>
> foo 1,2,"three";
>


The equivalent to:

  foo(1, 2, bar("a", "b"))

is...

  foo 1, 2, bar "a", "b"

?

CoffeeScript has this problem, too.

Rick



>
> that is an equivalent of foo(1,2,"three");
>
> In this case grammar may look like:
>
> function-call:
>    <name-token> '(' <parameter-list> ')' // existing form
>    <name-token> <parameter-list> // proposal
>
> Where <parameter-list> is comma ',' separated list of expressions.
>
> Just to reduce that bracketing noise in syntax.
>
> --
> Andrew Fedoniouk.
>
> http://terrainformatica.com
> _______________________________________________
> es-discuss mailing list
> es-discuss at mozilla.org
> https://mail.mozilla.org/listinfo/es-discuss
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20130712/0e2d92e4/attachment-0001.html>
forbes at lindesay.co.uk (2013-07-12T13:55:11.049Z)
> ```js
> foo {one:1,two:2 };
> ```
>
> Semi-formally that syntax looks like:
>
> ```js
> function-call:
>    <name-token> '(' <parameter-list> ')' // existing form
>    <name-token> <object-literal> // proposal
> ```

Given:

```js
function foo(){ return 1; }
```

This is a valid function call:

```js
foo
()

// 1;
```

But this is valid, too (though, not a function call):

```js
foo  <-- identifier
{} <-- empty block

// function foo() { return 1; }
```

Also, I could be wrong, but wouldn't there need to be a way to disambiguate
UnaryExpression?

```js
typeof foo { one: 1, two: 2 }
```

Maybe this is not an issue, or easily dealt with?



> We can add even more generic form of function call:
> ```js
> foo 1,2,"three";
> ```


The equivalent to:

```js
foo(1, 2, bar("a", "b"))
```
is...

```js
foo 1, 2, bar "a", "b"
```

?

CoffeeScript has this problem, too.