why are setter/getter parameter lists restricted?

Michael Ficarra mficarra at shapesecurity.com
Mon May 11 17:38:57 UTC 2015

We all know getters must have no parameters and setters must have exactly
one parameter. But I recently encountered a bug in one of my projects where
default values were not being properly handled for setter parameters. The
only reason it would make sense to allow default values on a setter
parameter is if the use case of pulling the setter off the property
descriptor was considered. But if that use case was considered, wouldn't
the use case of setting an arbitrary function to the get/set fields of the
property descriptor be just as valid?

For consistency, either FormalParameters should be used in the
getter/setter parameter list positions or only BindingIdentifier and
BindingPattern should be allowed for the setter parameter.

Michael Ficarra
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.mozilla.org/pipermail/es-discuss/attachments/20150511/564d7fba/attachment.html>

More information about the es-discuss mailing list