Path: csiph.com!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: minforth Newsgroups: comp.lang.forth Subject: Re: Nested definitions Date: Wed, 2 Jul 2025 18:15:56 +0200 Lines: 57 Message-ID: References: <1f433fabcb4d053d16cbc098dedc6c370608ac01@i2pn2.org> <6ea4ccd1cb6ae8c828144444fe51fea9@www.novabbs.com> <70a3014f99baf5e43b32e1320d7b8cd482be04c1@i2pn2.org> <61ff078b04e03c7b65b6dff98f58b80b@www.novabbs.com> <2025Jun23.071834@mips.complang.tuwien.ac.at> <1042s2o$3d58h$1@dont-email.me> <1042vcf$3d58h$2@dont-email.me> Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Trace: individual.net 4QzrKHtJGMbP1hljWEpAfwJVEtTqLs4Pveas+WqttLkHJPWKgj Cancel-Lock: sha1:jkXdXtF5wTMQmC6YtUJVLQAj8B4= sha256:rYI0s6ojx1UKk8l7qrE/IHqVCq0ij3hgIQkCpQnwDRw= User-Agent: Mozilla Thunderbird In-Reply-To: <1042vcf$3d58h$2@dont-email.me> Xref: csiph.com comp.lang.forth:133925 Am 02.07.2025 um 11:50 schrieb Ruvim: > On 2025-07-02 13:02, minforth wrote: >> Am 02.07.2025 um 10:53 schrieb Ruvim: >>> On 2025-06-24 01:03, minforth wrote: >>> [...] >>> >>>> For me, the small syntax extension is a convenience when working >>>> with longer definitions. A bit contrived (:= synonym for TO): >>>> >>>> : SOME-APP { a f: b c | temp == n: flag z: freq } >>>> \ inputs: integer a, floats b c >>>> \ uninitialized: float temp >>>> \ outputs: integer flag, complex freq >>>>   <: FUNC < ... calc function ... > ;> >>> >>> BTW, why do you prefer the special syntax `<: ... ;>` >>> over an extension to the existing words `:` and `;` >>> >>>    : SOME-APP >>>       [ : FUNC < ... calc function ... > ; ] >>>       < ... > >>>    ; >>> >>> In this approach the word `:` knows that it's a nested definition and >>> behaves accordingly. >> Are you sure? gforth test: >> >> : APP 1 [ : func 2 ; ] func ;  ok >> app >> *the terminal*:2:1: error: Invalid memory address > > This is not standard, just like `<: ;>` > > My question is why did you introduce `<:` and `;>` instead of extending > the `:` and `;` behavior? > It came naturally and cheaply once I had XT: type locals. BTW, Gforth has them too. When called, normal locals push their value onto the stack. XT: locals also execute their pushed xt. Then, with quotations, embedded functions can be emulated: [: ... calc function ... ;] { xt: func } ... Whenever you subsequently call "func" within the enclosing parent word, the quotation is executed. The embedded function header is temporary and it does not occupy dictionary space after the end of the parent function. For the sake of my tired eyes, I just added some syntactic sugar: <: FUNC ... calc function ... ;> ... which does the same thing behind the scenes.