Proposal: ignored arguments
In my honest opinion, I don't see the benefit. Arrays are the only structure you can even do that in. And ES3 elision elements don't exist in strict mode.
As for unused arguments, I usually just see the normal arguments for the
interface, some of which just happen to be unused. I'd rather know what
they are regardless of if they're used, though, so it's easier to check
later on if you have to fix something. It's a little more descriptive than
arguments[3]
(or nothing).
In my honest opinion, I don't see the benefit. Arrays are the only structure you can even do that in. And ES3 elision elements don't exist in strict mode. As for unused arguments, I usually just see the normal arguments for the interface, some of which just happen to be unused. I'd rather know what they are regardless of if they're used, though, so it's easier to check later on if you have to fix something. It's a little more descriptive than `arguments[3]` (or nothing). On Fri, Mar 4, 2016, 00:33 Dan Kaplun <dbkaplun at gmail.com> wrote: > I'd like to gauge the feasibility of a new feature, akin to ignored > values in array destructuring > <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Ignoring_some_returned_values> > : > > function ignoredArgument (foo,,baz) { >> return foo+baz; >> } >> console.log(ignoredArgument(1,2,3) === 4); > > > > Which could replace this common idiom, alleviating the need for an unused > variable: > > function ignoredArgument (foo,_,baz) { >> return foo+baz; >> } >> console.log(ignoredArgument(1,2,3) === 4); > > > > Does this feature make sense for a proposal? Am I missing anything? > -- > —Dan Kaplun • dbkaplun at gmail.com • 216-236-4601 > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160304/d522a3c6/attachment-0001.html>
What about something like a bare .
? Putting nothing there seems a bit error prone, but using _
non-ideal, as it clashes with the common practice of binding utility libraries to that name. For linters, it’s nice to be able to treat unused variables as an unconditional error.
What about something like a bare `.`? Putting nothing there seems a bit error prone, but using `_` non-ideal, as it clashes with the common practice of binding utility libraries to that name. For linters, it’s nice to be able to treat unused variables as an unconditional error. > On Mar 4, 2016, at 12:53 AM, Isiah Meadows <isiahmeadows at gmail.com> wrote: > > In my honest opinion, I don't see the benefit. Arrays are the only structure you can even do that in. And ES3 elision elements don't exist in strict mode. > > As for unused arguments, I usually just see the normal arguments for the interface, some of which just happen to be unused. I'd rather know what they are regardless of if they're used, though, so it's easier to check later on if you have to fix something. It's a little more descriptive than `arguments[3]` (or nothing). > > > On Fri, Mar 4, 2016, 00:33 Dan Kaplun <dbkaplun at gmail.com <mailto:dbkaplun at gmail.com>> wrote: > I'd like to gauge the feasibility of a new feature, akin to ignored values in array destructuring <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Ignoring_some_returned_values>: > > function ignoredArgument (foo,,baz) { > return foo+baz; > } > console.log(ignoredArgument(1,2,3) === 4); > > > Which could replace this common idiom, alleviating the need for an unused variable: > > function ignoredArgument (foo,_,baz) { > return foo+baz; > } > console.log(ignoredArgument(1,2,3) === 4); > > > Does this feature make sense for a proposal? Am I missing anything? > -- > —Dan Kaplun • dbkaplun at gmail.com <mailto:dbkaplun at gmail.com> • 216-236-4601 > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org <mailto:es-discuss at mozilla.org> > https://mail.mozilla.org/listinfo/es-discuss <https://mail.mozilla.org/listinfo/es-discuss> > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160304/0154cb0b/attachment.html>
I don't see the benefit of allowing this in function definitions (why encourage bad design?), but I could see the benefit for function calls, where
function someFunk (foo, bar, baz) {...}
someFunk( 1,,3 )
would be the same as
function someFunk (foo, bar, baz) {...}
someFunk( 1, undefined, 3 )
Well, if an argument can be undefined like that then there might be bad design there too, IMO.
/#!/JoePea
I don't see the benefit of allowing this in function definitions (why encourage bad design?), but I could see the benefit for function calls, where ```js function someFunk (foo, bar, baz) {...} someFunk( 1,,3 ) ``` would be the same as ```js function someFunk (foo, bar, baz) {...} someFunk( 1, undefined, 3 ) ``` Well, if an argument can be undefined like that then there might be bad design there too, IMO. /#!/JoePea On Mar 4, 2016 3:33 AM, "Alan Johnson" <alan at breakrs.com> wrote: > What about something like a bare `.`? Putting nothing there seems a bit > error prone, but using `_` non-ideal, as it clashes with the common > practice of binding utility libraries to that name. For linters, it’s nice > to be able to treat unused variables as an unconditional error. > > On Mar 4, 2016, at 12:53 AM, Isiah Meadows <isiahmeadows at gmail.com> wrote: > > In my honest opinion, I don't see the benefit. Arrays are the only > structure you can even do that in. And ES3 elision elements don't exist in > strict mode. > > As for unused arguments, I usually just see the normal arguments for the > interface, some of which just happen to be unused. I'd rather know what > they are regardless of if they're used, though, so it's easier to check > later on if you have to fix something. It's a little more descriptive than > `arguments[3]` (or nothing). > > On Fri, Mar 4, 2016, 00:33 Dan Kaplun <dbkaplun at gmail.com> wrote: > >> I'd like to gauge the feasibility of a new feature, akin to ignored >> values in array destructuring >> <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Ignoring_some_returned_values> >> : >> >> function ignoredArgument (foo,,baz) { >>> return foo+baz; >>> } >>> console.log(ignoredArgument(1,2,3) === 4); >> >> >> >> Which could replace this common idiom, alleviating the need for an unused >> variable: >> >> function ignoredArgument (foo,_,baz) { >>> return foo+baz; >>> } >>> console.log(ignoredArgument(1,2,3) === 4); >> >> >> >> Does this feature make sense for a proposal? Am I missing anything? >> -- >> —Dan Kaplun • dbkaplun at gmail.com • 216-236-4601 >> _______________________________________________ >> es-discuss mailing list >> es-discuss at mozilla.org >> https://mail.mozilla.org/listinfo/es-discuss >> > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > > > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss > > -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160304/5b118a4a/attachment.html>
A parameter in a function definition might be ignored if it’s meant to be called as a callback, but you it doesn’t care about some of the info passed in.
A parameter in a function definition might be ignored if it’s meant to be called as a callback, but you it doesn’t care about some of the info passed in. > On Mar 4, 2016, at 11:28 AM, /#!/JoePea <joe at trusktr.io> wrote: > > I don't see the benefit of allowing this in function definitions (why encourage bad design?), but I could see the benefit for function calls, where > > ```js > function someFunk (foo, bar, baz) {...} > someFunk( 1,,3 ) > ``` > > would be the same as > > ```js > function someFunk (foo, bar, baz) {...} > someFunk( 1, undefined, 3 ) > ``` > > Well, if an argument can be undefined like that then there might be bad design there too, IMO. > > /#!/JoePea > > On Mar 4, 2016 3:33 AM, "Alan Johnson" <alan at breakrs.com <mailto:alan at breakrs.com>> wrote: > What about something like a bare `.`? Putting nothing there seems a bit error prone, but using `_` non-ideal, as it clashes with the common practice of binding utility libraries to that name. For linters, it’s nice to be able to treat unused variables as an unconditional error. > >> On Mar 4, 2016, at 12:53 AM, Isiah Meadows <isiahmeadows at gmail.com <mailto:isiahmeadows at gmail.com>> wrote: >> >> In my honest opinion, I don't see the benefit. Arrays are the only structure you can even do that in. And ES3 elision elements don't exist in strict mode. >> >> As for unused arguments, I usually just see the normal arguments for the interface, some of which just happen to be unused. I'd rather know what they are regardless of if they're used, though, so it's easier to check later on if you have to fix something. It's a little more descriptive than `arguments[3]` (or nothing). >> >> >> On Fri, Mar 4, 2016, 00:33 Dan Kaplun <dbkaplun at gmail.com <mailto:dbkaplun at gmail.com>> wrote: >> I'd like to gauge the feasibility of a new feature, akin to ignored values in array destructuring <https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Ignoring_some_returned_values>: >> >> function ignoredArgument (foo,,baz) { >> return foo+baz; >> } >> console.log(ignoredArgument(1,2,3) === 4); >> >> >> Which could replace this common idiom, alleviating the need for an unused variable: >> >> function ignoredArgument (foo,_,baz) { >> return foo+baz; >> } >> console.log(ignoredArgument(1,2,3) === 4); >> >> >> Does this feature make sense for a proposal? Am I missing anything? >> -- >> —Dan Kaplun • dbkaplun at gmail.com <mailto:dbkaplun at gmail.com> • 216-236-4601 <tel:216-236-4601> >> _______________________________________________ >> es-discuss mailing list >> es-discuss at mozilla.org <mailto:es-discuss at mozilla.org> >> https://mail.mozilla.org/listinfo/es-discuss <https://mail.mozilla.org/listinfo/es-discuss> >> _______________________________________________ >> es-discuss mailing list >> es-discuss at mozilla.org <mailto:es-discuss at mozilla.org> >> https://mail.mozilla.org/listinfo/es-discuss <https://mail.mozilla.org/listinfo/es-discuss> > > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org <mailto:es-discuss at mozilla.org> > https://mail.mozilla.org/listinfo/es-discuss <https://mail.mozilla.org/listinfo/es-discuss> > > _______________________________________________ > es-discuss mailing list > es-discuss at mozilla.org > https://mail.mozilla.org/listinfo/es-discuss -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20160304/65b29698/attachment.html>
I'd like to gauge the feasibility of a new feature, akin to ignored values in array destructuring:
function ignoredArgument (foo,,baz) { return foo+baz; } console.log(ignoredArgument(1,2,3) === 4);
Which could replace this common idiom, alleviating the need for an unused variable:
function ignoredArgument (foo,_,baz) { return foo+baz; } console.log(ignoredArgument(1,2,3) === 4);
Does this feature make sense for a proposal? Am I missing anything?