-
Notifications
You must be signed in to change notification settings - Fork 0
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
Constructs for non-sequential control flow #37
Comments
Do we need one? I had hoped that the last thing in a block would be the return value (i.e., like Ocaml's ; operator) I realize that's not Monad-friendly, but I'm not sure we need to go that far. |
The return I'm talking about here is distinct from Haskell's monadic I would like to write:
I know we eventually want some better syntax for this kind of thing, but I would also like to write this directly (i.e., I think this is what it should desugar down to). The alternatives, without a
Or some kind of unsafe match:
|
I see. I think this is the tip of a more complicated iceburg that is "what sort of control-flow constructs should we support?" In some sense, the example you've written are more like mid-test loops, which is a very interesting form of control-flow, something like
or just something like
Java eschews gotos for named loops and breaks. Esterel has an even more complicated mechanism where blocks of code may be started and terminated from both outside and from within (through exceptions). My feeling is that traditional C-like return is rather a blunt instrument in our setting (which function are you returning from, exactly?). |
Yeah, I was trying to write a more complicated example earlier when I realized that having a I do really like the idea of named loops/breaks; a further extension of this is to have breaks take an expression, so I can do this kind of thing:
So this just strictly a control flow issue; perhaps the question isn't just "where do I want control to go", but "what value do I want to give to the parent construct once I terminate it (whether that be a loop, closure, par, or wait)". |
I just realized that so far we haven't added
return
into the parser yet... It's not totally clear cut to me how this should be done, so I wanted to write down a few thoughts/propose some ideas here.I think we should make
return
a layout keyword, and parse for'return' '{' expr '}'
. This looks odd at first, and is not what I had in mind, but here is why I don't like the alternatives where it isn't a layout keyword, and return expressions are strictly concatenative:return
is at the same precedence as application (juxtaposition), writingreturn f x
is a type error, so if we are forced to writereturn (f x)
orreturn $ f x
. I think it should be at a higher precedence compared to other atomic expressions because something likef return
shouldn't make any sense.return
is magically at a higher precedence than application (juxtaposition), something likereturn return a b
becomes ambiguous.What are people's thoughts?
The text was updated successfully, but these errors were encountered: