I think that "nothing" wins over "dot" or "underscore" for marking unused
positions, for one simple reason: it is implemented for years in every engines
in constructs like:
var myArray = [ , , third]
So it seems more natural to me to have something like: function( , , z) { /*
... */ }
But anyway, if one day I'll need more than one unused parameter, I would first
ask me seriously if it would not be better to refactor my function's signature
with something like:
function f({z: z}) { /* ... */ }
f({x: first, y: second, z: third})
instead of:
function f( , , z) { /* ... */ }
f(first, second, third)
Claude
Le 30 déc. 2012 à 13:06, Axel Rauschmayer <[email protected]> a écrit :
> It wouldn’t be breaking if it was the only identifier that one was allowed to
> use multiple time, right?
>
> But I do like the idea of the dot. Would be nice for destructuring arrays,
> too:
>
> let [., ., third] = myArray;
>
> On Dec 30, 2012, at 13:01 , Andreas Rossberg <[email protected]> wrote:
>
>> On 30 December 2012 12:50, Axel Rauschmayer <[email protected]> wrote:
>>> It would actually be nice to have that as a feature: If the variable name is
>>> `_` then it can be used multiple times. It’s a nice, self-descriptive way of
>>> saying that you don’t care about a parameter value.
>>
>> That underscore wildcard is the exact syntax used in functional
>> languages, and very useful, I agree. In JS, that syntax would be a
>> breaking change, unfortunately. But we could use something else (e.g.
>> I proposed '.' in the past).
>>
>> /Andreas
>
> --
> 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
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss