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 knowledge and breaking changes like `=` would; it also does not require having multiple identifiers for the same variable.
Perhaps I may be wrong here, but having multiple identifiers/bindings to the same variable seems fraught with confusion. On Tue, Jul 14, 2015 at 6:03 AM, Alexander Kit <alex....@atmajs.com> wrote: > 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 foo(bar:a=1,baz:b=2,bak:c=3){console.log(b)} > foo(baz:2); > > // Explicit Label > function foo (bar = 1, baz: myVar = 2, bak = 3) { > console.log(myVar); > } > foo (baz: 2); > > // Minified (same) > function foo(bar:a=1,baz:b=2,bak:c=3){console.log(b)} > foo(baz:2); > ``` > > And when talking about static analysis, then it is really not always > possible to determine the global function variables, but within the > scope(s) it shouldn't be the problem. But anyway, the labels will cover all > the cases. > > Sorry for bothering, if I miss something, > Alex > > On 13 July 2015 at 14:54, Benjamin Gruenbaum <benjami...@gmail.com> wrote: > >> 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 justify the additional cost or the overhead, that >> current solutions like destructing aren't enough and so on. Even if we all >> agreed that we want named parameters, and we agreed in general lines how it >> should be done, and we convinced the TC, there would still be a lot of work >> to actually "decide' they should make it to ES. >> >> So I suggest we close this thread and anyone who feel strongly about >> including named parameters should work on a concrete proposal :) >> >> Cheers, >> Benjamin >> >> >> On Mon, Jul 13, 2015 at 3:50 PM, Michał Wadas <michalwa...@gmail.com> >> wrote: >> >>> 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 >>> some other function at minify time. >>> >>> So: you can't rely on optional parameters in any CDN-distributed file >>> (because your minifier doesn't know about it's pre-minification >>> identifiers), minifier have to avoid any parameters names clash at any >>> cost. >>> >>> Possible solution: add gramar explicitly declare optional parameters >>> by keyword to avoid minifaction of their names names. >>> >> >> > > _______________________________________________ > es-discuss mailing list > es-discuss@mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > >
_______________________________________________ es-discuss mailing list es-discuss@mozilla.org https://mail.mozilla.org/listinfo/es-discuss