| Deutsch English Français Italiano |
|
<ba23b24f79e8d236230992b114e7ca6f@www.novabbs.com> View for Bookmarking (what is this?) Look up another Usenet article |
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: <ba23b24f79e8d236230992b114e7ca6f@www.novabbs.com>
References: <1f433fabcb4d053d16cbc098dedc6c370608ac01@i2pn2.org> <7e21117d37c506cccd8e79323c416fd1@www.novabbs.com> <1021bsd$31o0d$1@dont-email.me> <b5802b3faad00b9a4397e1e445561681d0cd6ce5@i2pn2.org> <6ced001912d95b520dad9d25a6014342@www.novabbs.com> <60ca19340523b1ddfa4a2cbf1ac0995cb185cdcb@i2pn2.org> <nnd$16a55d5e$0e5ab22d@1d9c51e25014f149> <bdc732e87e38233e9e23f254b2326cf2@www.novabbs.com> <nnd$1a4144e5$43cad09f@b57c0b5013a1f2ab> <6ea4ccd1cb6ae8c828144444fe51fea9@www.novabbs.com> <70a3014f99baf5e43b32e1320d7b8cd482be04c1@i2pn2.org> <bfc6dc31af5bcbe4b4b0a2ccba8167e3@www.novabbs.com> <a8647abe1ce54c9c55c558f571761214a7c9d0f0@i2pn2.org> <61ff078b04e03c7b65b6dff98f58b80b@www.novabbs.com> <nnd$15d62a05$79f87aeb@2d18b2c67eb1f6e0> <f3fbac3a6e57ccf7465fff66180ac9e1@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.
--