-
Notifications
You must be signed in to change notification settings - Fork 19
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) )
All reactions
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
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.
All reactions
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.
All reactions
What are 'labeled' yields, is it a pattern or a directive
All reactions
It's a pattern. The idea is that yield has an additional (potentially implicit) argument: the identity of the generator coroutine that is yielding.