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
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
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
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
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
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
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
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
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
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
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
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
(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);
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
```
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
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
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
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 })
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
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
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?
21 matches
Mail list logo