nadako / haxe-coroutines

41 stars 5 forks source link

coroutine state serialization #16

Open nadako opened 3 years ago

nadako commented 3 years ago

(from https://github.com/nadako/haxe-coroutines/issues/15#issuecomment-782758999)

We could probably have the coroutine state exposable as an object rather just being a bunch of closure captured local vars and then provide a way to pass a custom object when creating the coroutine. This should be enough to have serializable coroutines as long as everything in the state object is serializable.

What I'm not sure yet is whether we could provide type safety for such objects.

Simn commented 5 months ago

This issue seems to have far-reaching consequences for the overall design and makes me lean towards explicitly representing coroutines as class instances after all. While there are some advantages to the current TFunction-based approach, I'm worried that it might come at the cost of extensibility. Will think about this some more...