Liste des Groupes | Revenir à cl forth |
On 23-06-2025 23:03, minforth wrote:LOL ... I admit being a very non-canonical old guy :O)On Mon, 23 Jun 2025 5:18:34 +0000, Anton Ertl wrote:>
>minforth@gmx.net (minforth) writes:>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 ;
What is the advantage of using this extension over the Forth-2012:
>
: spin {: a b c :} c b a ;
>
?
Obviously, there is no advantage for such small definitions.
>
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 ... > ;>
\ emulated embedded function using { | xt: func }
< ... calc something ... > := temp
< ... calc other things ... > := freq / basic formula
< ... calc other things ... > := flag
< ... calc correction ... > := freq / better estimation
;
>
While working on such things, I can focus my eyes on the formulas,
all local values are visible in one place, and I don't have to
worry about tracking the data stack(s) for lost/accumulated items.
>
As I said, it is nothing spectacular, just helpful. And to my own
eyes, it looks neater. ;-)
>
And before dxf yowls again: it is still Forth. :o)
Well.. Technically everything written in Forth is Forth. But it is not
canonical Forth - because if it were canonical Forth, we would have
covered locals in "Starting Forth" - and we didn't.
>
Now, let's assume we found we were wrong. But there was a chapter in
"Thinking Forth" called "The stylish stack" - not "The stylish locals".
As a matter of fact, it states that "the stack is not an array" -
meaning: not randomly accessible. And what are locals? Right. Randomly
accessible.
>
So, what is this? It's a feeble imitation of C. It's not part of the
original design. Because if it were part of the original design, you
would find out what it means to think differently. This is merely C
thinking. Nothing else. Certainly not Forth thinking.
>
Les messages affichés proviennent d'usenet.