-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Normative: add set methods #3306
Conversation
Rather than suggest changes here, I've filed a PR against the set-methods branch: #3308 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In isDisjointFrom, there's a "Set thisSize to the number of elements in O.[[SetData]]." line, but there's a bunch of other places that use SetDataSize. I see the difference - the AO skips empty values, the referenced line does not - but is that a problem? it seems like they should maybe all skip empty values?
<emu-alg> | ||
1. If _obj_ is not an Object, throw a *TypeError* exception. | ||
1. Let _rawSize_ be ? Get(_obj_, *"size"*). | ||
1. Let _numSize_ be ? ToNumber(_rawSize_). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
does this (and the below ToIntegerOrInfinity coercion) conflict with your "no coercion" initiative?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup, but there wasn't much appetite to retroactively apply that to existing stage 3 proposals.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If I was you, I would bring this one up. It's not like it will be hard or risky to do at this point.
Not a problem - the subsequent lines explicitly handle |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM otherwise.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Since "set" is a verb—and an especially common one in this specification at that, frequently paired with "get"—the new operation names strike me as a bit cumbersome (e.g., "SetDataHas" reads like "set the 'dataHas' of something" at first blush, rather then the "check if setData has a value" actually describing it). It would be nice to avoid such confusion by renaming them to avoid a leading "set" noun. Suggestions:
- SetDataHas → IsInSetData
- SetDataIndex → IndexInSetData
- SetDataSize → SizeOfSetData
I am aware that this deviates from the convention of starting operation names with the type of their first parameter, but a) that convention is not universal, cf. Operations on Objects, and b) the benefits of deviation seem to outweigh the drawbacks in this case.
spec.html
Outdated
<emu-clause id="sec-getsetrecord" type="abstract operation"> | ||
<h1> | ||
GetSetRecord ( | ||
_obj_: an ECMAScript language value, | ||
): either a normal completion containing a Set Record or a throw completion |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"Get" seems like an inappropriate prefix for an operation that constructs something new. Suggestion:
<emu-clause id="sec-getsetrecord" type="abstract operation"> | |
<h1> | |
GetSetRecord ( | |
_obj_: an ECMAScript language value, | |
): either a normal completion containing a Set Record or a throw completion | |
<emu-clause id="sec-createsetrecord" type="abstract operation"> | |
<h1> | |
CreateSetRecord ( | |
_obj_: an ECMAScript language value, | |
): either a normal completion containing a Set Record or a throw completion |
(cf. CreateListIteratorRecord and Temporal Create*Record methods like CreateDurationRecord for this pattern, and also Make{DataView,TypedArray}WithBufferWitnessRecord and other "Make" operations or even "New" operations like NewObjectEnvironment for alternatives, although I think "Make" is more often used to create language values and "New" for environment records. I would also like to address existing uses of the "Get" name like GetIteratorFromMethod, but at least this PR can avoid the bad precedent)
Addressed @michaelficarra comments. @gibson042 Re: naming, I lightly agree, but since this has already been implemented in various engines with explicit references to these names I'm inclined to keep them at this point. I don't think the benefits of marginally better names is worth having different names in engines vs the spec. |
- suggested changes (to the set-methods PR) (#3308)
See proposal.