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).

Some languages even interpret any id with '_'-prefix as wildcard, and
warn about uses as likely errors. Btw, the existing duplicate-parameter
error feature smells of should-be-a-warning-not-an-error.

But '_' is in popular use in JS, there being few good short identifiers.

How about moving the early error from parameter list to parameter
use? If a parameter isn't used, even if duplicated, it isn't likely to be
an error (*), and this would allow for wildcard use. If a duplicate
parameter is used at all, that seems to be the case to guard against.

Claus

(*) Though one can always construct a case where something is
   an error, eg: function(a,a) { return b } // meant a,b instead of a,a


_______________________________________________
es-discuss mailing list
es-discuss@mozilla.org
https://mail.mozilla.org/listinfo/es-discuss

Reply via email to