function invocation with just commas for explicit undefined optional arguments in the middle

Cyril Auburtin cyril.auburtin at gmail.com
Fri Nov 1 09:10:31 UTC 2019


yes true, it's even more annoying with eslint, you have to configure it
with https://eslint.org/docs/rules/no-unused-vars#argsignorepattern for
example

To be fair I considered this case mostly for `Array.from({length: n}, (,i)
=> i)`, but it's easier to forget that comma. What's preferable is a whole
new syntax for ranges anyway (some people proposed
https://github.com/tc39/proposal-slice-notation/pull/32)

So in the end, having to ignore arguments is probably a sign of a 'bad'
design, or at least other possible better workarounds

On Thu, Oct 31, 2019 at 5:23 PM Jeremy Martin <jmar777 at gmail.com> wrote:

> I'm not sure I find the reduced readability argument compelling on this
> one. The alternatives suggested (throwaway variables or crowding meaningful
> parameters with `undefined`) don't get clean scores on that front either,
> IMO.
>
> Simply eliding a parameter seems like a nice example of terse/expressive
> syntax. /2-cents
>
>
> On Wed, Oct 30, 2019 at 4:21 PM Cyril Auburtin <cyril.auburtin at gmail.com>
> wrote:
>
>> I proposed it a long time ago
>> https://esdiscuss.org/topic/ignoring-arguments
>>
>> but I agree with Tab Atkins nowadays, it would hurt readability
>>
>> On Wed, Oct 30, 2019 at 9:34 AM Naveen Chawla <naveen.chwl at gmail.com>
>> wrote:
>>
>>> I tend to agree and one thing I like in good code is "glanceability" -
>>>
>>> the ability to "glance" and see what's going on.
>>>
>>> If I have
>>>
>>> doStuff(bar,, foo,, far)
>>>
>>> vs
>>>
>>> doStuff(bar, foo,, far)
>>>
>>> they don't look too different, but really they are. I normally break
>>> params into separate lines so I wouldn't have this problem, but there's the
>>> risk overall.
>>>
>>> I like that a motivational factor for introducing a language feature is
>>> "reducing the likelihood of bugs", and in my mind this one seems to very
>>> slightly increase it
>>>
>>> On Tue, 29 Oct 2019 at 18:49, Tab Atkins Jr. <jackalmage at gmail.com>
>>> wrote:
>>>
>>>> On Tue, Oct 29, 2019 at 9:06 AM manuelbarzi <manuelbarzi at gmail.com>
>>>> wrote:
>>>> > ```
>>>> > fun('a', 'b',, 'd',, 'f')
>>>> > ```
>>>>
>>>> While this does technically match up with arrays, I find the the array
>>>> behavior unreadable and unintuitive (especially with the exception for
>>>> the final comma), and I'd prefer that syntax quirk not spread to other
>>>> list-like syntax constructs.
>>>>
>>>> Passing `undefined` is simply and easy enough; if it's too long you
>>>> can shave off three characters by spelling it `void 0`. Or put a `var
>>>> _;` at the top of your script and use that.
>>>>
>>>> ~TJ
>>>> _______________________________________________
>>>> 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
>>
>
>
> --
> Jeremy Martin
> 661.312.3853
> @jmar777 <https://twitter.com/jmar777> / @j <https://stream.live/j>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20191101/dadb3e21/attachment-0001.html>


More information about the es-discuss mailing list