Note that one of the main inspirations for the effects system here was this paper.
@aidanhs
perhaps some effects need a context arg for some functions
Just picking on this example, the idea is that the handler is the context, so effect methods would take a &self arg.
how does this actually get implemented? Monomorphisation of every function per effect combination?
That’s the idea, yeah. There would be a global set of pointers to the handler data for each currently active effect though.
@Ixrec
Are any of today’s stable and unstable mechanisms for allocation, panicking, async I/O, and blocking I/O forward-compatible with this? What would it take to make them compatible?
I’ll need to track down all the relevant APIs and check. Briefly: for allocation, panicking and blocking IO, existing standard library functions could be re-implemented to just call the underlying effect. The core/std libraries would come equipped with handlers which are present when main is called. Async IO would need to be re-done, something like mio would have to become part of the Io interface so that a non-blocking effect handler could be implemented.
Pretend I have a library that subscribes to Twitter updates…
The problem with this example is that you’re calling process_updates twice in parallel. If process_updates takes a &mut self (which it should do) then this is statically impossible, the task which is suspended on Io::print_stdout is still mutably borrowing the TwitterFeed. Generally, any race condition which is hard or impossible to cause today using threads should be equally hard or impossible to cause when you swap threads for green threads. You should get the same compile errors.