Path: news.eternal-september.org!eternal-september.org!feeder3.eternal-september.org!news.quux.org!news.nk.ca!rocksolid2!i2pn2.org!.POSTED!not-for-mail From: minforth@gmx.net (minforth) Newsgroups: comp.lang.forth Subject: Re: Parsing =?UTF-8?B?dGltZXN0YW1wcz8=?= Date: Mon, 23 Jun 2025 10:02:44 +0000 Organization: novaBBS Message-ID: References: <1f433fabcb4d053d16cbc098dedc6c370608ac01@i2pn2.org> <7e21117d37c506cccd8e79323c416fd1@www.novabbs.com> <1021bsd$31o0d$1@dont-email.me> <6ced001912d95b520dad9d25a6014342@www.novabbs.com> <60ca19340523b1ddfa4a2cbf1ac0995cb185cdcb@i2pn2.org> <6ea4ccd1cb6ae8c828144444fe51fea9@www.novabbs.com> <70a3014f99baf5e43b32e1320d7b8cd482be04c1@i2pn2.org> <61ff078b04e03c7b65b6dff98f58b80b@www.novabbs.com> <755ae8f9a73d167def41e6d96d951021@www.novabbs.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Injection-Info: i2pn2.org; logging-data="1687205"; mail-complaints-to="usenet@i2pn2.org"; posting-account="BZ29EnRIXfdX99fE+pfHgueF2xuF1KvSpLJsfuOZy3Y"; User-Agent: Rocksolid Light X-Rslight-Posting-User: 0338a3da6f3e9c9f1401b365bcd9c3ed8de2227a X-Rslight-Site: $2y$10$K82sPWMW6bKNsQBT9.ft9uXL/rDPQPsLK04tNAx39MOaIfEiaGMM6 X-Spam-Checker-Version: SpamAssassin 4.0.0 On Mon, 23 Jun 2025 5:40:37 +0000, mhx wrote: > On Sun, 22 Jun 2025 21:27:40 +0000, minforth wrote: > > [..] >> So, I made me a small extension to the locals word set. Using your >> example SPIN (abc — cba), I can define it as follows: >> : SPIN { a b c == c b a } ; \ no need for additional code before ; >> or likewise for floats, doubles, strings, matrices >> : FSPIN { f: a b c == c b a } ; >> : DSPIN { d: a b c == c b a } ; >> : "SPIN { s: a b c == c b a } ; >> : MSPIN { m: a b c == c b a } ; >> Code generation and register optimization is the computer's job. >> >> SPIN/STOW or similar microexamples can, of course, be defined quickly >> with classic Forth stack juggling too. The power of the extension >> becomes more apparent with mixed parameter types and/or more parameters, >> and of course, with some non-trivial algorithm to solve. > > Do you mean your compiler automatically handles/allows combinations > like > ... 22e-12 69. A{{ ( F: -- a ) ( D: -- b ) ( M: -- c ) SPIN ... > > I found that handling mixed types explodes the code that needs > to be written for a simple compiler like, e.g., Tiny-KISS . It > would be great if that can be automated. I don't know if I got you right, because as previously defined, SPIN expects three integers on the data stack. However, following your idea, a mixed SPIN could be defined e.g. : XSPIN { f: a d: b m: c == c b a } ; that can work with ... 22e-12 69. A{{ XSPIN ... I think gforth has allowed mixed type locals for a long time, so they are nothing really special. The only new word is == which pushes the locals following == on the stack before the word terminates with a ; or EXIT. This releaves you of the need to keep track of the data stack. A brief stack depth check can also catch some mistakes. I always found the conventional syntax wasteful, where everything after a -- does nothing but inform the reader. --