Leopold Toetsch wrote:
Sure. But I've no confirmation of a compiler writer that its possible. Annotating PIR can only work for nested closures. If libraries are involved you are out of luck.
And we have such code already in library/Streams/Sub.imc.
I've been thinking of what could be implemented using continuations. Some possible ideas:
- multiple returns from regexp matches - lazy lists. In particular gather/take - junctions - coroutines - resumable exceptions
Thing is, we can't know what the Real World perl6 code is going to look like. If it turns out that continuations are The Way to implement both junctions and gather/take construct, 'out of luck' is a good description of the ensuing fun and merryment. Basically, any PMC can be silently swapped with a junction, possibly making anything that uses it backtrack (what are the junctions supposed to be implemented as, anyway?) and I can imagine that lots of production perl6 code will have gather/takes all over the place - they look like an utterly nice way to construct a list.
My point is that continuations are rare because mainstream languages (with a single exception) don't support them.
BTW, I wonder if there are any research papers on the topic of register allocation in presence of continuations. I just looked at Citeseer, but a quick cursory search didn't come up with anything useful.
Miro
