It should be possible to write a set of macros that does a delimited continuation transform, like in Scala:
with delimit:
...
@callcc
def func(cont):
...
...
Much of the same techniques would apply, and the transform would probably be similar to what the tail call macro does.
Edit: On the other hand, we wouldn't be able to use the @cps annotation on functions containing callcc, like the Scala transformation, since we won't get that information at transform-time without types. This would require an explicit annotation (c%?) at call site of all the functions that contain naked callccs; not ideal but perhaps acceptable
Closing this for now, since I don't have time to do it, it's not a priority and I don't think anyone else will find implementing a CPS transform that enjoyable
It should be possible to write a set of macros that does a delimited continuation transform, like in Scala:
Much of the same techniques would apply, and the transform would probably be similar to what the tail call macro does.
Edit: On the other hand, we wouldn't be able to use the
@cps
annotation on functions containingcallcc
, like the Scala transformation, since we won't get that information at transform-time without types. This would require an explicit annotation (c%
?) at call site of all the functions that contain nakedcallcc
s; not ideal but perhaps acceptable