I don't think declaring and destructuring formal parameters all at once
improves clarity.Once you get beyond a toy example, the parameter list, like a
sentence with many phrases, becomes awkward, causing readers difficulty in
following the meaning.
Technical writing guidelines include the use of concise sentences.
I opine that this guideline applies to code as well.
Your proposed syntax puts the reference to the whole on the left and the
destructuring pattern on the right, the opposite of destructuring assignment.
The existing meaning of the exclamation mark is to negate the meaning of what
follows.That seems an odd choice to overload with the meaning "keep a
reference".C++ uses the ampersand for declaring a reference. Not everyone knows
C++, but at least it has some basis in an existing language.
If I felt this was needed, my version would look like this:```const
someMiddlewareFn = ({name} &original, {name: newName} &updated, next) => {```
However, I like to think of ECMAScript as somewhere near the happy medium on a
programming language continuum that puts the terseness of APL at one extreme
and the verbosity of COBOL on the other. I think this is an unnecessary nudge
in the terse direction.
_______________________________________________
es-discuss mailing list
[email protected]
https://mail.mozilla.org/listinfo/es-discuss