I started programming with Python, and I was really confused by concepts like coroutines and closures.
Now I think I know them on some superficial level, but I've never felt that "enlightement" moment, so I choose to learn Clojure. I bought the book by Stuart Halloway and it's good, but when I looked at the index there were no words like coroutine or continuation. I googled them, but there's nothing there either.
So, my question is:
Does Clojure have continuations or coroutines to do tasks like ping-ponging without a stack overflow?
Python example (though standard Python does not support a fully-featured version of this symmetric coroutine):
def ping():
while 1:
print "ping"
function to switching to pong
def pong():
while 1:
function to switching to ping
print "pong"
Best Answer
Clojure doesn't have call/cc, but you don't want undelimited continuations anyway.
David Nolen wrote a delimited continuations library for Clojure. Try it out!