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

SameValueZero calls should probably be prefixed by ? #203

Closed
domenic opened this Issue Nov 17, 2015 · 5 comments

Comments

Projects
None yet
4 participants
@domenic
Member

domenic commented Nov 17, 2015

Let me know if I'm missing something. But my understanding is that SameValueZero can return an abrupt completion. Throughout the spec it is used as if it cannot, e.g. "If SameValueZero(numberLength, elementLength) is false, throw a RangeError exception."

Probably also ToNumber and ToString?

I am unclear what to do here for Array.prototype.includes, given the inconsistency.

domenic added a commit to tc39/Array.prototype.includes that referenced this issue Nov 17, 2015

@anba

This comment has been minimized.

Show comment
Hide comment
@anba

anba Nov 17, 2015

Contributor

ReturnIfAbrupt and its ?-prefix form are only used when an abrupt completion can occur. Calling SameValueZero(numberLength, elementLength), where numberLength and elementLength are both number values, will never return an abrupt completion, so ReturnIfAbrupt gets omitted.

Contributor

anba commented Nov 17, 2015

ReturnIfAbrupt and its ?-prefix form are only used when an abrupt completion can occur. Calling SameValueZero(numberLength, elementLength), where numberLength and elementLength are both number values, will never return an abrupt completion, so ReturnIfAbrupt gets omitted.

@bterlson

This comment has been minimized.

Show comment
Hide comment
@bterlson

bterlson Nov 18, 2015

Member

Just to add to what @anba says, choosing to omit ? should be a very deliberate choice - you're signaling implementers that the operation is not expected to result in an abrupt completion (or that you're working on completion values). Right now we have an ambiguity between those two cases so I am thinking we will want another operator (say, !) to mean assert you didn't get an abrupt completion and unwrap the completion record's value.

Member

bterlson commented Nov 18, 2015

Just to add to what @anba says, choosing to omit ? should be a very deliberate choice - you're signaling implementers that the operation is not expected to result in an abrupt completion (or that you're working on completion values). Right now we have an ambiguity between those two cases so I am thinking we will want another operator (say, !) to mean assert you didn't get an abrupt completion and unwrap the completion record's value.

@bterlson bterlson closed this Nov 18, 2015

@rossberg

This comment has been minimized.

Show comment
Hide comment
@rossberg

rossberg Nov 18, 2015

Member

A serious problem with not having ? in cases like this is that it amounts to an implicit conversion from CompletionRecord to Value, by implicitly projecting .[[value]]. IMO, that is pretty bad and should be avoided in the spec. I already dislike the implicit injection in 6.2.2.2/3, but at least that is specified, whereas projection is not AFAICS. If you want to avoid ?, I think introducing ! for such cases is highly preferable.

Member

rossberg commented Nov 18, 2015

A serious problem with not having ? in cases like this is that it amounts to an implicit conversion from CompletionRecord to Value, by implicitly projecting .[[value]]. IMO, that is pretty bad and should be avoided in the spec. I already dislike the implicit injection in 6.2.2.2/3, but at least that is specified, whereas projection is not AFAICS. If you want to avoid ?, I think introducing ! for such cases is highly preferable.

@anba

This comment has been minimized.

Show comment
Hide comment
@anba

anba Nov 18, 2015

Contributor

I already dislike the implicit injection in 6.2.2.2/3, but at least that is specified, whereas projection is not AFAICS.

Projection is also specified in 6.2.2.2:

Any reference to a Completion Record value that is in a context that does not explicitly require a
complete Completion Record value is equivalent to an explicit reference to the [[value]] field of the
Completion Record value unless the Completion Record is an abrupt completion.

Contributor

anba commented Nov 18, 2015

I already dislike the implicit injection in 6.2.2.2/3, but at least that is specified, whereas projection is not AFAICS.

Projection is also specified in 6.2.2.2:

Any reference to a Completion Record value that is in a context that does not explicitly require a
complete Completion Record value is equivalent to an explicit reference to the [[value]] field of the
Completion Record value unless the Completion Record is an abrupt completion.

@rossberg

This comment has been minimized.

Show comment
Hide comment
@rossberg

rossberg Nov 18, 2015

Member

Ah, okay, thanks, I missed that. I think that should go into a separate section, or the section title should be renamed. (I'd still prefer avoiding implicit conversions in that direction altogether.)

Member

rossberg commented Nov 18, 2015

Ah, okay, thanks, I missed that. I think that should go into a separate section, or the section title should be renamed. (I'd still prefer avoiding implicit conversions in that direction altogether.)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment