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

Editorial: more obvious syntax for macros #2384

Closed
bakkot opened this issue Apr 13, 2021 · 7 comments
Closed

Editorial: more obvious syntax for macros #2384

bakkot opened this issue Apr 13, 2021 · 7 comments

Comments

@bakkot
Copy link
Contributor

bakkot commented Apr 13, 2021

Macros like ReturnIfAbrupt and IfAbruptRejectPromise are called like AOs, but they can have effects on the control flow and aliases in caller, which is confusing.

We should make it more obvious at the callsites that these are not normal AOs.

(I don't think this extends to the ? and ! macros, since uses of those symbols do not look like a normal AO invocation.)

@ljharb
Copy link
Member

ljharb commented Apr 13, 2021

Perhaps we could find all non-symbolic uses of ReturnIfAbrupt, and find a way to replace it with ?/!?

Then, perhaps we could come up with a symbolic form of IfAbruptRejectPromise?

@bakkot
Copy link
Contributor Author

bakkot commented Apr 13, 2021

Then, perhaps we could come up with a symbolic form of IfAbruptRejectPromise?

And IfAbruptCloseIterator, presumably? I think it's probably better to have some way of marking macros in general, rather than trying to invent unique syntax for each one.

@jmdyck
Copy link
Collaborator

jmdyck commented Apr 13, 2021

Shorthands that are invoked like abstract ops:

  • ReturnIfAbrupt
  • Await
  • IfAbruptRejectPromise
  • NormalCompletion
  • ThrowCompletion

However, I think NormalCompletion and ThrowCompletion could be defined as regular abstract ops.

@ljharb
Copy link
Member

ljharb commented Apr 13, 2021

Both already are, no? If not, they should be.

@jmdyck
Copy link
Collaborator

jmdyck commented Apr 13, 2021

Well, they say they're abstract operations, but they're defined as shorthands, so they're weird.

jmdyck added a commit to jmdyck/ecma262 that referenced this issue Apr 14, 2021
... as regular abstract operations.

See
- tc39#1142 (comment) and following
- tc39#2384 (comment) and following
jmdyck added a commit to jmdyck/ecma262 that referenced this issue Jul 18, 2021
... as regular abstract operations.

See
- tc39#1142 (comment) and following
- tc39#2384 (comment) and following
ljharb pushed a commit to jmdyck/ecma262 that referenced this issue Aug 18, 2021
... as regular abstract operations.

See
- tc39#1142 (comment) and following
- tc39#2384 (comment) and following
mathiasbynens pushed a commit to mathiasbynens/ecma262 that referenced this issue Oct 18, 2021
... as regular abstract operations.

See
- tc39#1142 (comment) and following
- tc39#2384 (comment) and following
@ExE-Boss
Copy link
Contributor

We could probably prefix their names with a % sign, which is what assembly languages generally do, and it’s probably more visible than suffixing them with an ! without any other syntax highlighting, e.g.:

This would also solve #2498.

@michaelficarra
Copy link
Member

Closing as duplicate of #2498.

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

No branches or pull requests

5 participants