why are setter/getter parameter lists restricted?
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.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the es-discuss