Path: ...!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: Operator =?UTF-8?B?b3ZlcmxvYWRpbmc/?= Date: Thu, 1 Aug 2024 16:35:26 +0000 Organization: novaBBS Message-ID: References: <698bd09c6db27738ab6a1c3222aba1e1@www.novabbs.com> <2024Jul25.140858@mips.complang.tuwien.ac.at> <2024Jul27.173555@mips.complang.tuwien.ac.at> <2024Aug1.153554@mips.complang.tuwien.ac.at> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: i2pn2.org; logging-data="1118460"; mail-complaints-to="usenet@i2pn2.org"; posting-account="0+ejqm+s29REto3A2x2P4fP+XaUXf51pZgtYBR0nEqI"; User-Agent: Rocksolid Light X-Spam-Checker-Version: SpamAssassin 4.0.0 X-Rslight-Posting-User: d2a19558f194e2f1f8393b8d9be9ef51734a4da3 X-Rslight-Site: $2y$10$feBLBI/2j1P219OCEE7wIeOeKiCWlHpAfMybGxx8DXahwWyy7dVMC Bytes: 2637 Lines: 33 On Thu, 1 Aug 2024 13:35:54 +0000, Anton Ertl wrote: >>I don't know if this would be good enough for a Lisp/Scheme programmer, >>but it works for my needs. And look Ma, no garbage collection. :-) > > But then, with > > | : INIT { a } > | [[: a ;]] \ read counter > | [[: 1 +to a ;]] ; \ increment counter > | DEFER count IS count > | DEFER read IS read > | 5 INIT > | COUNT COUNT READ -> should give 7 > > is A not gone after INIT is finished, and COUNT and READ will do ... > interesting things? Of course not. When the compiler encounters the first [[: it lays down code to capture the contents INIT's locals stack (environment) when INIT is executed. All subsequent [[: "closures" are just quotations which inject the captured stack segment into their own locals stack, and update the captured environment when finished and before their own locals stack is discarded. In this way these "closure-flavoured quotations" see an updated A i.e. shared upvalue, whenever one of them is called again. Execute INIT a second time and the previously captured environment will be overwritten. The code is only a few lines long. I don't know if Pascal does similar things, or if funarg problems are a show-stopper. And of course this simple scheme is not OOP, but when it comes quasi for free and is handy enough for small applications..