Re: Named Paramters

2015-07-31 Thread joe
In principle, I agree with Bucara re: the ({}) syntax. Unfortunately this is often too slow to use in practice. Everyone keeps hoping browser vendors will come up with a way to optimize out small object allocations, but I think that's a pipe dream, because we do have a language that handles

Re: Named Paramters

2015-07-31 Thread Michał Wadas
Proposal that do not conflict with minimifiers: - Functions have optional named parameters in any place of argument definition. Optionality is defined by presence of hash character at beginning of parameter name. Optional parameters CAN be placed after rest parameter. These parameters can be

Re: Named Paramters

2015-07-31 Thread Soni L.
Could add f{} as sugar for f({}), and make engines optimize f{}? (no positional arguments though) On 31/07/15 12:00 PM, Michał Wadas wrote: Proposal that do not conflict with minimifiers: - Functions have optional named parameters in any place of argument definition. Optionality is defined by

Re: Named Paramters

2015-07-30 Thread Axel Rauschmayer
On 12 Jul 2015, at 16:05, Luke Scott l...@webconnex.com wrote: Personally I'd rather be able to name parameters without creating an object. The intermediate object seem like something that JavaScript engines could eliminate by statically analyzing the code. I’m wondering whether any engine

Re: Named Paramters

2015-07-14 Thread Alexander Kit
Seems everybody is pessimistic about this. But using optional `labels` would solve any problem with the minifiers. ```javascript // Not minified (Labels are optional, default are the variable names) function foo (bar = 1, baz = 2, bak = 3) { console.log(baz); } foo (baz: 2); // Minified function

Re: Named Paramters

2015-07-14 Thread Bradley Meck
There are a couple of people tossing around named parameter ideas that have different identifiers than the argument identifier. What is wrong with what Gary Guo originally said with `foo(bar: 5)`, it uses `:` for mapping similar to an object literal, but does not require having contextual

Re: Named Paramters

2015-07-13 Thread Michał Wadas
In fact, it's impossible. And when the arguments are renamed during the minification, all the labels in function calls can be minified accordingly too. You can't statically determine which function will be called. Minifier CAN'T know in general case if your $(selector='wow') calls jQuery or

Re: Named Paramters

2015-07-13 Thread Benjamin Gruenbaum
If we _wanted_ to add named parameters, we would _probably_ have a _different_ name for the named parameter inside the function and outside the function. ```js function foo(x as y){ } foo(y = 5); ``` Or something like that. That said, I'm not convinced we _need_ named parameters, that they

Re: Named Paramters

2015-07-13 Thread Alexander Kit
This is extremely for the optional parameters important function foo (bar, bak=1, qux=2) { } // here I want `bar` to be default, but the `quux` take another value foo(5, qux: 3); People often suggest object destruction here, but it is then just a workaround. And when the arguments are renamed

Re: Named Paramters

2015-07-12 Thread Denis Pushkarev
So you propose don't compress arguments of all functions? :) ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Named Paramters

2015-07-12 Thread Benjamin Gruenbaum
I think my original post might have been confusing so allow me to clarify. I'm not suggesting to add named parameters to the language, I did not intend to start a discussion about named parameters' merits vs passing an object literal (I thing Axel had a blog about that a while ago). What I'm

Re: Named Paramters

2015-07-12 Thread Allen Wirfs-Brock
On Jul 12, 2015, at 1:48 AM, Benjamin Gruenbaum wrote: I think my original post might have been confusing so allow me to clarify. I'm not suggesting to add named parameters to the language, I did not intend to start a discussion about named parameters' merits vs passing an object literal

Re: Named Paramters

2015-07-12 Thread Peter van der Zee
(A minifier that breaks your code is a broken minifier and should never be a valid argument for these cases) On Sun, Jul 12, 2015 at 10:29 AM, Denis Pushkarev zloir...@zloirock.ru wrote: 1. It would break backwards compatibility: ```js var bar = 1; if(baz(bar))foo(bar = 5);

Re: Named Paramters

2015-07-12 Thread Gil Tayar
It won't break if Gary Guo's idea is used, i.e. use a colon instead of an equal. On Sun, Jul 12, 2015 at 11:29 AM, Denis Pushkarev zloir...@zloirock.ru wrote: 1. It would break backwards compatibility: ```js var bar = 1; if(baz(bar))foo(bar = 5); console.log(bar); // 5 in some cases ```

Re: Named Paramters

2015-07-12 Thread Luke Scott
On Jul 12, 2015, at 2:48 AM, Benjamin Gruenbaum benjami...@gmail.commailto:benjami...@gmail.com wrote: I think my original post might have been confusing so allow me to clarify. I'm not suggesting to add named parameters to the language, I did not intend to start a discussion about named

Re: Named Paramters

2015-07-12 Thread Denis Pushkarev
1. It would break backwards compatibility: ```js var bar = 1; if(baz(bar))foo(bar = 5); console.log(bar); // 5 in some cases ``` 2. Code with this feature will be broken after minification. ___ es-discuss mailing list es-discuss@mozilla.org

RE: Named Paramters

2015-07-12 Thread Gary Guo
If we really need this, you may want to use colon to replace the assignment operator in your example. foo(bar: 5) ___ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss

Re: Named Paramters

2015-07-12 Thread Benjamin Gruenbaum
No, I didn't mean simulating them via an object literal. I mean actual named parameters like in Python or C# for example. Are there any plans to peruse that and if so what is the status? On Sun, Jul 12, 2015 at 12:56 AM, Bucaran jbuca...@me.com wrote: What about: foo({ bar: 5 })

Re: Named Paramters

2015-07-12 Thread Benjamin Gruenbaum
Thanks for the clarification. On Sun, Jul 12, 2015 at 5:05 PM, Luke Scott l...@webconnex.com wrote: On Jul 12, 2015, at 2:48 AM, Benjamin Gruenbaum benjami...@gmail.com wrote: I think my original post might have been confusing so allow me to clarify. I'm not suggesting to add named

Re: Named Paramters

2015-07-11 Thread Bucaran
What about: foo({ bar: 5 }) function foo ({ baz, bak, bar }) { console.log(bar) } Or is there anything else you are considering or something I am missing. Regards On Jul 12, 2015, at 6:47 AM, Benjamin Gruenbaum benjami...@gmail.com wrote: Hey, I

Named Paramters

2015-07-11 Thread Benjamin Gruenbaum
Hey, I wasn't able to find information about the current status of a named parameters propsosal: // as in: foo(bar = 5); // logs 5 function foo(baz, bak, bar){ console.log(bar); } Is this being considered? Was it decided for/against? Anyone working on it?