Skip to content

Navigation Menu

Sign in
Sign up

Is it worth adding suspend.all? #58

Answered by tlively
oovm asked this question in Q&A
Discussion options

Can we add a command that corresponds to yield*/yield from semantics, that is, get all values ​​from a generator (cont).

This command can be simulated with multiple instructions

(suspend.all $k)
(loop $relay
 (suspend $yield (local.get $k))
 (br $relay)
)
You must be logged in to vote

This instruction would probably be too high-level for WebAssembly. Different producers would want different behavior. For example, should the yielded values be stored in a memory? in a table? in an array? dropped? It's better to provide the low-level building blocks and let producers implement exactly what they need rather than trying to provide such high-level operations directly.

Replies: 3 comments 1 reply

Comment options

This instruction would probably be too high-level for WebAssembly. Different producers would want different behavior. For example, should the yielded values be stored in a memory? in a table? in an array? dropped? It's better to provide the low-level building blocks and let producers implement exactly what they need rather than trying to provide such high-level operations directly.

You must be logged in to vote
0 replies
Answer selected by oovm
Comment options

Following on from Thomas's remarks: definitely too high-level and language specific.
Note that a source language wanting to support such patterns has a better alternative: 'labeled' yields.

You must be logged in to vote
1 reply
Comment options

What are 'labeled' yields, is it a pattern or a directive

Comment options

It's a pattern. The idea is that yield has an additional (potentially implicit) argument: the identity of the generator coroutine that is yielding.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /