I like the idea, maybe we could do the following:
foo(posArg1, posArg2, name1: x, name2: y)
as syntactic sugar for:
foo(posArg1, posArg2, { name1: x, name2: y })
Axel
On Jul 12, 2013, at 6:22 , 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
>
> 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";
>
> 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
> [email protected]
> https://mail.mozilla.org/listinfo/es-discuss
>
--
Dr. Axel Rauschmayer
[email protected]
home: rauschma.de
twitter: twitter.com/rauschma
blog: 2ality.com
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss