Liste des Groupes | Revenir à cl forth |
On 20-06-2025 10:46, LIT wrote:Mr. FIFO, that Forth of yours bites you from time to time?
>> The claim made 40 years ago was: "Forth's heavy use of the stack for
>> parameter passing [...] it is easy for the beginner to run away with
>> the idea that the stack operators should be employed at every
>> opportunity." The suggestion being there's so much traffic one must
>> use stack juggling to solve it.
>
> How many years ago it was made — it doesn't that matter.
> Pythagorean theorem was made over 2500 years ago, and
> AFAIK it's still actual.
>
>> That's the fear and bogeyman that's regularly trotted out about
Forth.
>> But is it true? None of the colon definitions the authors provide
in
>> their book would indicate it. Each used 0, 1, 2 and occasionally 3
>> parameters. Any variables they employed were sparse and global in
>> nature.
>>
>> How about more comprehensive applications?
>
> Then just compare the two examples from "my"
> thread "May the numbers speak". Is really the
> solution that uses strings of "r> drop nip s>d"
> etc. more clear and comprehensible? Oh, really?
>
> It's what we were talking about - not about
> "one of yours that had 154 colon definitions".
>
> --
You can repair such things by using new stack paradigms. I've added
several ones, most of 'em inspired by others. E.g
>
"swap 3OS with TOS" (SPIN, a b c -- c b a)
"DUP 2OS" (STOW, a b -- a a b)
>
-- and several Return Stack operators like R'@, R"@ and RDROP. They're
not just shorthand, but also a template for stack manipulations.
>
The R-stack operators are excellently suited to store (almost)
constants. The D-stack operators document the intentions of the
programmer.
>
I'm sure your example comes from a "clean up" operation. It cleans up
the stacks. Most probably TOS is a return value, that has to be extended
to a double word (most likely because it is interfaced with a double
word word).
>
One of the techniques I developed is to figure out which stack diagram
is most suited for the next set of operations. You do your stuff to get
there, document the resulting scheme - and the rest of your stack
manipulations are simple and shallow.
>
But of course, you have to do the work. If you're incapable or too lazy
to do the work, yeah, then you will find Forth bites you. Note that C is
a very nice language as well. Beats Forth performance wise - so, what's
there not to like :)
>
Hans Bezemer
Les messages affichés proviennent d'usenet.