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

Editorial: usage of "!" #1097

Closed
jmdyck opened this Issue Feb 10, 2018 · 5 comments

Comments

Projects
None yet
4 participants
@jmdyck
Collaborator

jmdyck commented Feb 10, 2018

(Picking up from #1096 (comment).)

For an operation (abstract, syntax-directed, or type-directed), we can distinguish two possibilities:

  • The operation can, under some circumstances, return an abrupt completion.
  • The operation cannot, under any circumstances, return an abrupt completion.

For convenience here, we can refer to "can-throw operations" and "can't-throw operations". (There are abrupt completions other than throw-completions, but the latter appear to be of more interest.)

For a can-throw operation, we expect that generally, its invocations will be prefixed by "!" or "?", depending on whether or not the circumstances of the invocation guarantee that the return value won't be an abrupt completion.

But the question raised in PR #1096 relates to can't-throw operations: should their invocations be prefixed by "!" ?


Some numbers: (These are my counts. Your mileage may vary.)

The spec has 4247 operation-invocations. Of these,

  • 2387 are unprefixed,
  • 1576 are prefixed with "?", and
  • 284 are prefixed with "!".

Of those prefixed with "!",

  • 244 are invoking can-throw operations, and
  • 40 are invoking can't-throw operations.
@ljharb

This comment has been minimized.

Show comment
Hide comment
@ljharb

ljharb Feb 10, 2018

Member

I would expect and desire every abstract operation to be prefixed by a ? or a ! - to me, the lack of a prefix means that it returns a Completion Record, which means the algorithm must be checking whether it’s abrupt or not.

That the number of changes to achieve this consistency is large doesn’t, to me, detract from the value of the change.

Member

ljharb commented Feb 10, 2018

I would expect and desire every abstract operation to be prefixed by a ? or a ! - to me, the lack of a prefix means that it returns a Completion Record, which means the algorithm must be checking whether it’s abrupt or not.

That the number of changes to achieve this consistency is large doesn’t, to me, detract from the value of the change.

@jmdyck

This comment has been minimized.

Show comment
Hide comment
@jmdyck

jmdyck Feb 10, 2018

Collaborator

to me, the lack of a prefix means that it returns a Completion Record, which means the algorithm must be checking whether it’s abrupt or not.

Indeed, if you take the view that every operation returns a completion record, then you have to use '?' or '!' if you want to explicitly inline-extract the [[Value]]. (Of course, you could also rely on implicit [[Value]]-extraction.)

However, I don't subscribe to that view.

Collaborator

jmdyck commented Feb 10, 2018

to me, the lack of a prefix means that it returns a Completion Record, which means the algorithm must be checking whether it’s abrupt or not.

Indeed, if you take the view that every operation returns a completion record, then you have to use '?' or '!' if you want to explicitly inline-extract the [[Value]]. (Of course, you could also rely on implicit [[Value]]-extraction.)

However, I don't subscribe to that view.

@littledan

This comment has been minimized.

Show comment
Hide comment
@littledan

littledan Feb 10, 2018

Member

I like the idea of maintaining metadata somewhere about which abstract operations return completion records (i.e., which may throw) and which do not. cc @domenic who I believe suggested this in the past.

This issue reminds me a bit of tc39/proposal-bigint#10 : There are some concepts for when things sort of implicitly become completion records and when not, and it's not immediately obvious to everyone what's going on.

Member

littledan commented Feb 10, 2018

I like the idea of maintaining metadata somewhere about which abstract operations return completion records (i.e., which may throw) and which do not. cc @domenic who I believe suggested this in the past.

This issue reminds me a bit of tc39/proposal-bigint#10 : There are some concepts for when things sort of implicitly become completion records and when not, and it's not immediately obvious to everyone what's going on.

@domenic

This comment has been minimized.

Show comment
Hide comment
@domenic
Member

domenic commented Feb 10, 2018

#486 #496 #253

@jmdyck

This comment has been minimized.

Show comment
Hide comment
@jmdyck

jmdyck Feb 11, 2018

Collaborator

Dang, I forgot about #486. I'll close this as a duplicate of that.

Collaborator

jmdyck commented Feb 11, 2018

Dang, I forgot about #486. I'll close this as a duplicate of that.

@jmdyck jmdyck closed this Feb 11, 2018

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