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

Make Junctions short-curcuit similar to how `and`/`or` do #1963

zoffixznet opened this issue Jun 25, 2018 · 2 comments


None yet
3 participants
Copy link

commented Jun 25, 2018

This is really for The Future™, once our Junctions autothread; filing this so it doesn't get lost.

This is following on the original discussion in the docs that Junctions were planned to short-circuit more than they do now, i.e. in the code below, one or more sub calls might not be executed at all, if one of the already-called subs returned a truthy value:

    if a() | b() | c() {
        say "At least one of the routines was called and returned a truthy value"

We probably should look at this after auto-threading is implemented, because we'll possibly will need to use the same mechanism we might use to figure out whether auto-threading the junction is worth it to decide whether thunking the args for short-circuiting is worth it too.

zoffixznet added a commit to perl6/doc that referenced this issue Jun 25, 2018

Reword Junction short-cuircuting portion
Closes #2120 D#2120
- Expand short-circuiting behavior to include same type of shortcircuiting as
    performed in `and`/`or` ops
- Document it as possible future language feature per
    #2120 (comment)
- Feature proposed in R#1963 rakudo/rakudo#1963

This comment has been minimized.

Copy link

commented Jun 25, 2018


This comment has been minimized.

Copy link
Contributor Author

commented Jun 25, 2018

My feeling is that we cannot guarantee anything in this respect

Correct, there would be no order to it and we might execute more than needed.

The user-specific caution would be that they should not expect all sub calls in a() | b() | c() to actually be called, not that they can rely that only one of them would be called as long as it returns True.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.