Newsgroups: comp.lang.forth Subject: Re: Back & Forth - Co-routines References: <871pw5wqp4.fsf@nightsong.com> <0170b27dd93d28515881d13546bd404c@www.novabbs.com> <87wmdwunwk.fsf@nightsong.com> From: albert@spenarnc.xs4all.nl X-Newsreader: trn 4.0-test77 (Sep 1, 2010) Originator: albert@cherry.(none) (albert) Message-ID: Organization: KPN B.V. Date: Wed, 12 Feb 2025 13:49:48 +0100 Path: ...!news.tomockey.net!2.eu.feeder.erje.net!feeder.erje.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!feed.abavia.com!abe004.abavia.com!abp003.abavia.com!news.kpn.nl!not-for-mail Lines: 52 Injection-Date: Wed, 12 Feb 2025 13:49:48 +0100 Injection-Info: news.kpn.nl; mail-complaints-to="abuse@kpn.com" Bytes: 3041 In article <87wmdwunwk.fsf@nightsong.com>, Paul Rubin wrote: >minforth@gmx.net (minforth) writes: >> Unfortunately, everything is very non-standard, as there is >> no multitasking wordset (for historical reasons?). >> A pity really, as co-operative multitasking existed very >> early on in Forth. > >I had thought there wasn't enough agreement about the wordset to >standardize it, and the same thing happened for cross development. But >at least for multitasking, there is reasonable shared understanding >about how it should work, at least in the cooperative case. > >> Then it would be easier to have better discussions about coroutines >> (the original topic of this thread) or ownership of closure objects >> and different variants of GC. > >I think these fancy closures are mostly of interest to language geeks >and not so much in the old-fashioned Forth spirit. Coroutines don't >seem that important if you have multitasking. Anton's GC is great and I >think cooperative multitasking wouldn't affect it much, if you don't >mind the collection pauses. It would simply block during collection. Look at python: they have decorators. In Forth this looks like: ' aap ' noot decorate Execute `aap (e.g. .S) before each invocation of `noot This works nicely with coroutines. In ciforth it is actually implemented. (also undecorated of course) In ciforth the canonical example is " { &i EMIT .S ;: &o EMIT .S } 'somethingbuggy decorated " The `;: ( `CO ) takes care that the second part is executed after each invocation of `somethingbuggy. Note that this is ideal for Heisenbug's, where you cannot insert testoutput because the bug disappears as soon as memory is shifted. Downplaying coroutines is an indication that you have not realised the potential. [I don't care much about closures, maybe the same applies to me about closures.] Groetjes Albert -- Temu exploits Christians: (Disclaimer, only 10 apostles) Last Supper Acrylic Suncatcher - 15Cm Round Stained Glass- Style Wall Art For Home, Office And Garden Decor - Perfect For Windows, Bars, And Gifts For Friends Family And Colleagues.