Path: csiph.com!eternal-september.org!feeder.eternal-september.org!nntp.eternal-september.org!.POSTED!not-for-mail From: Kragen Javier Sitaker Newsgroups: comp.lang.forth Subject: coroutines (was Re: dynamic scoping in Forth in one line of code) Date: Thu, 03 Sep 2026 20:38:30 -0300 Organization: Primarily biological and memetic Lines: 20 Message-ID: <87mrtxzz0p.fsf_-_@debian> References: <87bjamc5xh.fsf@debian> <874igd9fjt.fsf@debian> <875x0oa6fy.fsf@debian> <87ecfcld9r.fsf@nightsong.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit Injection-Date: Thu, 03 Sep 2026 23:38:34 +0000 (UTC) Injection-Info: dont-email.me; logging-data="161289"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18cZ4XN0zZtPYWgGu291PTd"; posting-host="9d8b1d041ffbfb92fa0be79acc76e4c5" User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/28.2 (gnu/linux) Cancel-Lock: sha1:XfO9q0Rk9Ip6ZSWLwcicMYu3xug= sha1:r5jsnG+KH3dghviP88xDSbB5OwU= sha256:cynvT05TxWfXfjdN5OPgHrvLXfwALypTvtqIg01q44s= sha1:lVyt2sCdehrdl2DWDCE71Ck4BFI= sha256:R3apnPCscGpXcoiiHiB3d26c4w42DM1fJs67g4EqY6A= Xref: csiph.com comp.lang.forth:135546 Paul Rubin writes: > Kragen Javier Sitaker writes: >> I think you’ve internalized it sufficiently that it’s not surprising to >> you, but it was surprising to me when I encountered it a year and a half >> ago, at which point I’d been programming for 43 years and occasionally >> programming in Forth for 27 years. Maybe I'm just a slow learner. > > The idea has been in the literature for a long time (it's discussed at > length in Knuth vol. 1 from 1968), No, no, I know what coroutines are; I learned about them last millennium when I read Knuth vol. 1. My copy has pencil annotations in the margin expressing my skepticism; but, since then I’ve used Icon generators, Python generators, Python asyncio, Prolog backtracking, and Lua “coroutines,” which might more precisely be called “threads”. What surprised me was the extremely parsimonious mechanism of Van der Horst’s `co`. Kragen