Coroutine iters in Common Lisp
vicsydev.blogspot.com
vicsydev.blogspot.com
Many Common Lisp implementations have threads so effectively, Common Lisp de facto supports coroutines.
I don't agree. Sometimes you don't want to pay the price of the OS context switch.
Anyway, in the context of the ANSI spec, threads were out of scope, but they could have done coroutines anyway.
> ... and delimited continuations
But CL doesn't have these, even de facto. Yes, there's CL-Cont, but it's pretty slow.
Much thanks to macros, as usual; without that support, the approach wouldn't really be feasible for general purpose use.
They can be used directly via a lower-level API or via the obtain/yield mechanism.
http://www.nongnu.org/txr/txr-manpage.html#N-01C4E6B4
Here is an example of obtain/yield wrapped in the object system to create green-thread-like objects:
http://www.nongnu.org/txr/rosetta-solutions-main.html#Synchr...
Some things are worth throwing out. For instance setq and setf are "onions in the varnish". Lisp has a set function which is rarely used. Because it exists, we cannot give the general assignment operator the name it wants: set. The q in setq refers to its historic relationship with set: "like set but with the var implicitly quoted". This relationship broke decades ago when Lisp went lexical: (setq x y) is (set 'x y) only when x is a dynamic var. And of course setq is redundant since every setq can be replaced with setf, and setf even replaces set since symbol-value is an accessor. Can I be blamed for not wanting to reproduce this baggage and just having one set macro?
It may seem like a small thing, but most programmers are used to assignment just being =. The name "set" is still reasonably acceptable. We see it in vi, some shells, and such. "set" with a gratuitous letter added for fifty-year-old reasons: not so much.