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

"Abort when" vs "abort these steps" #258

Open
jakearchibald opened this issue Jun 25, 2019 · 7 comments
Open

"Abort when" vs "abort these steps" #258

jakearchibald opened this issue Jun 25, 2019 · 7 comments

Comments

@jakearchibald
Copy link
Contributor

It feels like these definitions clash.

"Abort these steps" is more like return, but can be used when in parallel.

"Abort when" is more like break.

I'm not sure what the best solution is here. Either:

Replace "abort these steps" with "return". This might be confusing when in parallel. Will it be clear that "return" only ends the in parallel steps?

Replace "abort when" with "break when". This feels like it fits the behavior more accurately, as steps following the "abort when" block will run after breaking.

@domenic
Copy link
Member

domenic commented Jun 25, 2019

No solutions, but...

See #255 for my attempt at clarifying when "abort these steps" makes sense, although it's a bit stalled.

"Break when" might be confusing if used inside an actual loop where "break" is defined by Infra to mean something already.

@jakearchibald
Copy link
Contributor Author

"Break" could be redefined:

Within an iteration, "break" will skip over any remaining steps in an iteration, and skip over any remaining items as well, stopping the iteration. Within any other block of steps, "break" will skip the remaining steps.

This feels similar to how it behaves in JavaScript.

Maybe we have a better definition of "block of steps". I mean the direct children of the <ol>.

@GPHemsley
Copy link
Member

GPHemsley commented Jun 26, 2019

Isn't an "abort when" block really just a hidden loop wherein you're evaluating whether the abort condition is met in between the steps of the algorithm you're executing? (The comment suggests that the check needn't be between steps, but it has a caveat that the abort cannot happen when a value is mutated; in the example, the calculation and the mutation are really two separate steps artificially combined by "and", so I call shenanigans on that.)

Separately, throwing some more possible terms out there to get the juices flowing: halt, stop, last (as in "this is the last step", from Perl), exit. Might also consider more extensive use of throwing exceptions.

@jakearchibald
Copy link
Contributor Author

Isn't an "abort when" block really just a hidden loop wherein you're evaluating whether the abort condition is met in between the steps of the algorithm you're executing?

Yep. But if the condition becomes true, it only skips the rest of its inner steps, which is different to "abort these steps", which cancels the whole synchronously executing algorithm.

@GPHemsley
Copy link
Member

Since Domenic closed PR #255, let me copy my comment here:

More broadly, an algorithm is a set of steps. Just because you sometimes pass a set of steps into another set of steps doesn't make either set of steps any less of an algorithm. So you might want to differentiate between an intentionally-incomplete set of steps (like some sort of mix-in or partial function) from a nested-but-complete set of steps (like a direct function call or a callback argument), and then the language of how to exit the set of steps (either prematurely or at the end) might fall out from that (I hope).

@jakearchibald
Copy link
Contributor Author

Yeah, like a block vs a function in JS.

@GPHemsley
Copy link
Member

Hmm, another term that just came to mind: escape

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

No branches or pull requests

3 participants