Add variant of loop / Control with a return value#985
Add variant of loop / Control with a return value#985marzipankaiser wants to merge 3 commits intomainfrom
loop / Control with a return value#985Conversation
|
The question is whether |
|
FWIW, something relevant I tend to use somewhat often in my code is: effect breakWith[A](value: A): Nothing
def boundary[A] { body: => A / breakWith[A] }: A =
try body() with breakWith[A] { a => a }
def boundaryDefault[A] { body: => Unit / breakWith[A] } { default: => A } : A =
try { body(); default() } with breakWith[A] { a => a }The problem is that the semantics of A feature that could help accommodate all is "grouping" capabilities together with sub-effecting: effect Control[A] = { breakAt[A], break, continue }
def loop { body: {Control[A]} => Unit }: A // here we'd have "one" capability only to take care of
// but
def boundary { body: => A / breakAt[A] }: A |
Surprisingly, it seems to (see |
|
Yes, another alternative (since we only use |
|
(Mostly, I just wrote some code and missed something like this, so I tried to add it to stdlib directly.) |
|
@jiribenes Yes, I don't know what is the best solution generally for a |
Does this work (passing this kind of capability explicitly)? How could we even construct it? |
We discussed this before in #404 |
|
The CI failure is weird. |
|
I restarted the job since it might be flaky. |
|
I want to express interest in this again, ideally in the style of #404 (comment) |
This adds a variant of
loopwith a return value.Interestingly, overload resultion is able to resolve this, even when we do not use break. 🤔