d at domenic.me (2015-05-11T16:39:22.976Z)
Using array destructuring assignment and constraining linting rules, I
often find myself having to chose names for bindings I don't intent on
using. I usually end up using a conventional ignore name, such as _ignore,
which I "void" to shut up the linter without adding exceptions. Besides the
linting problem (which can be solved by refining the linting rules), it's
still a conceptually useless binding.
Here's a contrived example:
```js
const lastOfThree = ([first, second, third]) => third;
```
Which I usually end up rewriting:
```js
const lastOfThree = ([_ignore1, _ignore2, third]) => {
void _ignore1;
void _ignore2;
return third;
}
```
This problem doesn't exist when using objects, since only the fields
specified on the LHS are bound.
I realize the bigger topic behind non-binding match is refutable pattern
matching, as per
http://wiki.ecmascript.org/doku.php?id=strawman:pattern_matching, but being
able to dismiss a matched (or unmatched) value from a destructuring
assignment seems a very often desirable feature when programming in a
functional style (eg. working with lists represented as 2-element arrays).
Most functional-style languages have a non-binding matching feature.
This topic has been discussed in the following topics:
- https://esdiscuss.org/topic/conditional-catch
- https://esdiscuss.org/notes/2014-07-30
- https://esdiscuss.org/topic/conditional-catch-clause
Does anyone else feel the need for a specific means of dismissing a binding
from a destructuring assignment? Is pattern matching still on discussion?
Using array destructuring assignment and constraining linting rules, I often find myself having to chose names for bindings I don't intent on using. I usually end up using a conventional ignore name, such as _ignore, which I "void" to shut up the linter without adding exceptions. Besides the linting problem (which can be solved by refining the linting rules), it's still a conceptually useless binding. Here's a contrived example: const lastOfThree = ([first, second, third]) => third; Which I usually end up rewriting: const lastOfThree = ([_ignore1, _ignore2, third]) => { void _ignore1; void _ignore2; return third; } This problem doesn't exist when using objects, since only the fields specified on the LHS are bound. I realize the bigger topic behind non-binding match is refutable pattern matching, as per http://wiki.ecmascript.org/doku.php?id=strawman:pattern_matching, but being able to dismiss a matched (or unmatched) value from a destructuring assignment seems a very often desirable feature when programming in a functional style (eg. working with lists represented as 2-element arrays). Most functional-style languages have a non-binding matching feature. This topic has been discussed in the following topics: - https://esdiscuss.org/topic/conditional-catch - https://esdiscuss.org/notes/2014-07-30 - https://esdiscuss.org/topic/conditional-catch-clause Does anyone else feel the need for a specific means of dismissing a binding from a destructuring assignment? Is pattern matching still on discussion? Regards, -------------- next part -------------- An HTML attachment was scrubbed... URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150429/168ef78f/attachment.html>