Skip to content
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

Introduce a shorthand for ECMA262 abstract ops #539

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

jugglinmike
Copy link

@jugglinmike jugglinmike commented Feb 16, 2023

This patch is in service of gh-518.

I've implemented this using the definition name "throw-if-abrupt" because I can't get Bikeshed to use ? (U+003F) as a name. If we think this might limit adoption, I can inquire about modifying Bikeshed.

The new text (which I've largely copied from ECMA262) reduces ambiguity, but it does not eliminate it. There are ways of applying ? which do not match the example, even within Infra itself:

1. Return ? Call(%JSON.parse%, undefined, « string »).

...is not "otherwise equivalent to":

1. Let |result| be ? AbstractOperation().

For what it's worth, ECMA262 suffers from the same deficiency, though some folks have been trying to address it. @annevk do you feel that the ambiguity undermines the goal of this patch?


Preview | Diff

@annevk
Copy link
Member

annevk commented Feb 16, 2023

Would be interested in feedback from @jmdyck on this.

infra.bs Show resolved Hide resolved
infra.bs Outdated Show resolved Hide resolved
@jmdyck
Copy link

jmdyck commented Feb 16, 2023

As for the problems with defining ?, I probably don't have anything to say here beyond what I've said in tc39/ecma262#1573

@jugglinmike
Copy link
Author

Thank you, @jmdyck! I appreciate your encouragement to explain this more holistically. I couldn't find a way to expand the reasoning exactly according to the points you've outlined, but I hope the prose I've pushed up is sufficiently coherent, anyway.

Completion records aren't just for modelling exceptions-based flow; even if ECMAScript didn't have exceptions, it would still need completion records (or something like them) to model break+continue+return control flow.

Fair point. Those details don't seem necessary to explain the motivation or usage of this shorthand, though, so I've true to accommodate them simply by writing in less sweeping terms ("to model control flow interruptions such as thrown exceptions.")

As for the problems with defining ?, I probably don't have anything to say here beyond what I've said in tc39/ecma262#1573

After some more thought, I'm feeling like replicating 262's current (though imprecise) language still represents a meaningful step forward here. That said, I've also added a note to surface this consideration and help folks recognize when an improvement is available.

infra.bs Outdated Show resolved Hide resolved
infra.bs Outdated Show resolved Hide resolved
infra.bs Outdated Show resolved Hide resolved
@jmdyck
Copy link

jmdyck commented Feb 17, 2023

Those details don't seem necessary to explain the motivation or usage of this shorthand, though, so I've true to accommodate them simply by writing in less sweeping terms ("to model control flow interruptions such as thrown exceptions.")

Sounds good.

@jugglinmike
Copy link
Author

@annevk I think this is ready for another look!

Copy link
Member

@annevk annevk left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How does this end up being different from JS's ? shorthand? This definition doesn't actually define anything as far as I can tell.

@jmdyck
Copy link

jmdyck commented Feb 24, 2023

The difference is in the way that an abrupt completion is handled. In ECMAScript, it's simply returned (i.e., the algorithm using ? returns an abrupt completion), whereas here, its [[Value]] is thrown (i.e., the algorithm using ? throws an Infra-exception). Issue #518 explains the significance of that distinction.

@annevk
Copy link
Member

annevk commented Feb 24, 2023

Thanks for the refresher. So I think what needs to happen is that we state that normatively. And then have an example that illustrates it. And not have the normative requirements be made through examples.

Shawna1987

This comment was marked as spam.

Shawna1987

This comment was marked as spam.

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

Successfully merging this pull request may close these issues.

None yet

4 participants