Path: news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: peter Newsgroups: comp.lang.forth Subject: Re: Nested definitions Date: Thu, 3 Jul 2025 19:42:02 +0200 Organization: A noiseless patient Spider Lines: 105 Message-ID: <20250703194202.0000508f@tin.it> References: <1f433fabcb4d053d16cbc098dedc6c370608ac01@i2pn2.org> <1042s2o$3d58h$1@dont-email.me> <1043831$3ggg9$1@dont-email.me> <1046c6b$8gru$1@dont-email.me> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Injection-Date: Thu, 03 Jul 2025 19:42:04 +0200 (CEST) Injection-Info: dont-email.me; posting-host="7b84251294d655fb6d6ea67390ee9524"; logging-data="311095"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/OdvdJ2XxXqMAgvbii+Z3/ks/r7lEszg4=" Cancel-Lock: sha1:ArvZ9o3JHOBupI0PTkvLEyIbK3w= X-Newsreader: Claws Mail 4.3.0 (GTK 3.24.42; x86_64-w64-mingw32) On Thu, 3 Jul 2025 20:47:07 +0400 Ruvim wrote: > On 2025-07-03 17:11, albert@spenarnc.xs4all.nl wrote: > > In article <1043831$3ggg9$1@dont-email.me>, > > Ruvim wrote: > >> On 2025-07-02 15:37, albert@spenarnc.xs4all.nl wrote: > >>> In article <1042s2o$3d58h$1@dont-email.me>, > >>> Ruvim wrote: > >>>> 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 (:=3D synonym for TO): > >>>>> > >>>>> : SOME-APP { a f: b c | temp =3D=3D n: flag z: freq } > >>>>> \ inputs: integer a, floats b c > >>>>> \ uninitialized: float temp > >>>>> \ outputs: integer flag, complex freq > >>>>> =A0<: 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. > >>> > >>> Or it has not even know it, if [ is smart enough to compile a > >>> jump to after ]. > >> > >> This can be tricky because the following should work: > >> > >> create foo [ 123 , ] [ 456 , > >> > >> : bar [ ' foo compile, 123 lit, ] ; > >=20 > > If this bothers you, rename it in [[ ]]. > >=20 > > Once we enhance [ ] to do things prohibited by the standard, > > (adding nested definitions) I can't be bothered with this too much. >=20 >=20 > The standard does not prohibit a system from supporting nested=20 > definitions in whichever way that does not violate the standard > behavior. >=20 >=20 > Yes, something like "private[ ... ]private" is a possible approach, > and its implementation seems simpler than adding the smarts to `:` > and `;` (and other defining words, if any). >=20 > The advantage of this approach over "<: ... ;>" is that you can > define not only colon-definitions, but also constants, variables, > immediate words, one-time macros, etc. >=20 >=20 > : foo ( F: r.coefficient -- r.result ) > private[ > variable cnt > 0e fvalue k > : [x] ... ; immediate > ]private > to k 0 cnt ! > ... > ; >=20 > It's also possible to associated the word list of private words with > the containing word xt for debugging purposes. >=20 >=20 > -- > Ruvim >=20 In lxf I have module, private, public, end-module your example would be module private variable cnt 0e fvalue k : [x] ... ; immediate public : foo ( F: r.coefficient -- r.result ) to k 0 cnt ! ... ; end-module end-module will remove all headers from the private words in the module I am not found of mixing definitions inside others. BR Peter =20