Path: ...!news.misty.com!weretis.net!feeder9.news.weretis.net!news.nk.ca!rocksolid2!i2pn2.org!.POSTED!not-for-mail From: minforth@gmx.net (minforth) Newsgroups: comp.lang.forth Subject: Re: Back & Forth - Co-routines Date: Mon, 10 Feb 2025 01:30:01 +0000 Organization: novaBBS Message-ID: <63ac62f34dd6f15df0b5ff9b044b9bcd@www.novabbs.com> References: <874j1aycdt.fsf@nightsong.com> <3c3bdb056696f15c43fa512b5366002d@www.novabbs.com> <2025Feb6.135712@mips.complang.tuwien.ac.at> <3955434636b2a293c6a9c6d726ff6eae@www.novabbs.com> <2025Feb6.180659@mips.complang.tuwien.ac.at> <2cf9bd53562dae1241a161036e87cd6b@www.novabbs.com> <2025Feb8.120627@mips.complang.tuwien.ac.at> <87ed07vw8e.fsf@nightsong.com> <914f1d7f6d3e010799fec2544312f72f@www.novabbs.com> <87a5auwy2j.fsf@nightsong.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: i2pn2.org; logging-data="3506839"; mail-complaints-to="usenet@i2pn2.org"; posting-account="BZ29EnRIXfdX99fE+pfHgueF2xuF1KvSpLJsfuOZy3Y"; User-Agent: Rocksolid Light X-Rslight-Posting-User: 0338a3da6f3e9c9f1401b365bcd9c3ed8de2227a X-Spam-Checker-Version: SpamAssassin 4.0.0 X-Rslight-Site: $2y$10$MGaHpw4IUncF1VVxenpj1eZSAWXM6W/rJHQCTjxaxJkHSRXbwD35. Bytes: 2265 Lines: 27 On Sun, 9 Feb 2025 22:30:28 +0000, Paul Rubin wrote: > minforth@gmx.net (minforth) writes: >> FWIW a single quotation-based counter in another Forth: >> >> MinForth 3.6 (32 bit) >> # defer ctr ok >> # : init { n } [: n 1+ dup to n ;] ; ok >> # 4 init is ctr ok >> # ctr . 5 ok > > Questions: > > 1) where does the storage cell for n live, after init has returned? > > 2) what if you make more than one counter? > > 3) why did you use defer instead of something like CONSTANT? > > thanks 1) Briefly, details omitted: a copy of the locals stack frame of the outer function is inlined. Before execution of the quotation, this copy is inserted into the quotation's locals stack frame. 2) Won't work because there is only one copy per quotation 3) Convenience