lihaoyi / macropy

Macros in Python: quasiquotes, case classes, LINQ and more!
3.28k stars 178 forks source link

Delimited Continuations! #26

Closed lihaoyi closed 11 years ago

lihaoyi commented 11 years ago

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

lihaoyi commented 11 years ago

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