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

[WIP] Add a return statement #363

Draft
wants to merge 1 commit into
base: master
Choose a base branch
from
Draft

Conversation

jimbxb
Copy link
Collaborator

@jimbxb jimbxb commented Nov 13, 2022

This is a work-in-progress attempt at adding a return statement. In essence, it is the det dual of fail, causing a call to exit, but the call succeeds.

Some things are left to consider/get working correctly:

  • mode checking
    • currently return causes the determinism to be terminal, but I suspect this isn't correct. I want to say that nothing more can happen, but we haven't failed and terminal seemed the best fit here, but it isn't quite right, because there is more to go after the call
  • use blocks
    • any used resources must be reset to their value before the use block if return is encountered

Copy link
Owner

@pschachte pschachte left a comment

Choose a reason for hiding this comment

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

I don't think terminal is the right determinism for this. Terminal means that it will neither succeed nor fail. I think you'll need a new determinism that means something like "it has already succeeded so thoroughly that even if this is conjoined with other constraints, it automatically satisfies them". But then you'll need to work out how this determinism conjoins, disjoins, and otherwise combines with, all the other determinisms. This becomes tricky because none of the other determinisms is sensitive to procedure boundaries, and this one will need to be (procs shouldn't be declared to have this new determinism; and a proc all of whose branches have this determinism still has determinism det).

You can probably predict my next review comment: WYBE.md needs to be revised to explain return, and to clearly explain how it interacts with everything else, including loops, but also what if a return appears in one of the conditions in an if. There are probably other interactions I haven't thought of. It would be good to have a motivating example for this feature.

I couldn't see how you're handling variable binding in case of a return. It must be the case that all outputs of a proc are already bound when you reach a return, otherwise it must be reported as an error.

@jimbxb jimbxb closed this Nov 15, 2022
@jimbxb jimbxb reopened this Nov 15, 2022
@jimbxb jimbxb linked an issue Nov 15, 2022 that may be closed by this pull request
@jimbxb jimbxb marked this pull request as draft November 15, 2022 04:58
@jimbxb jimbxb changed the title Add a return statement [WIP] Add a return statement Nov 29, 2023
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

Successfully merging this pull request may close these issues.

Allow for an early return in a proc
2 participants