Ancestors

Toot

Written by yosh on 2025-01-24 at 00:45

Wait, so if for..in is the “consume” part of the iteration effect, I think break maps to a logical return, and continue maps to the next iteration.

I’ve seen people talk about “break with value” before - e.g. the loop exiting with a value. But I don’t think I’ve seen people talk about “continue with value before”.

The latter seems like it would rather neatly map to coroutines, wouldn’t it? E.g. continue 12u32; to resume the coroutine with a u32 could work?

=> More informations about this toot | More toots from yosh@toot.yosh.is

Descendants

Written by yosh on 2025-01-24 at 00:52

Yeah wait, and so if we could re-think of the last statement in a for-expression as being an implied continue.

By default hard-coded to () today. But for coroutines that could be loosened to allow for arbitrary types. So you could write something like the following to send values back into the underlying coroutine:

=> View attached media

=> More informations about this toot | More toots from yosh@toot.yosh.is

Written by yosh on 2025-01-24 at 00:54

Surely this is not a unique insight, right? I don’t think I’ve seen it before, but unless I’m missing something (which, to be fair, is entirely possible) this seems like… a pretty obvious mapping?

=> More informations about this toot | More toots from yosh@toot.yosh.is

Written by JP Sugarbroad on 2025-01-24 at 16:57

@yosh I think it makes the loop value confusing - it gets passed back on every person except the last, or is it passed back on the last? If the latter, what's the value of the overall loop?

=> More informations about this toot | More toots from taral@mastodon.social

Written by ∀ {α}, ∃ bugaevc := by rfl on 2025-01-24 at 05:21

@yosh or maybe rather require an explicit continue as a last statement in a loop body (as in, require the loop body to diverge)

=> More informations about this toot | More toots from bugaevc@floss.social

Proxy Information
Original URL
gemini://mastogem.picasoft.net/thread/113880569009860767
Status Code
Success (20)
Meta
text/gemini
Capsule Response Time
297.182225 milliseconds
Gemini-to-HTML Time
1.619373 milliseconds

This content has been proxied by September (3851b).