Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]

Liste des Groupes 
Sujet : Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]
De : the.beez.speaks (at) *nospam* gmail.com (Hans Bezemer)
Groupes : comp.lang.forth
Date : 11. Sep 2024, 10:02:00
Autres entêtes
Organisation : KPN B.V.
Message-ID : <nnd$545e2daa$4f8af75c@548f76d6156a46d8>
References : 1 2 3 4 5 6 7 8
User-Agent : Mozilla Thunderbird
On 10-09-2024 13:26, Paul Rubin wrote:
 > Hans Bezemer <the.beez.speaks@gmail.com> writes:
 >> What bothers me most technologically is that parameters flow through
 >> the stack undisturbed. You break that paradigm when using locals. With
 >> locals you *HAVE TO* create some kind of stack frame that you have to
 >> destroy when you exit.
 >
 > Forth programs very frequently end up juggling parameters and other data
 > to and from the return stack, instead of using locals.  Simple
 > implementations of locals put them in the return stack too.
 > "Destroying" the stack frame just means adjusting RP when the function
 > exits.  Usually a single instruction.
 >
 >> Needless to say this copying, releasing and stuff takes time.
 >
 > Similar to DUP (copy) or DROP (release).
 >
 >> In all honesty I must state that this overhead is not always
 >> translated to a diminished performance
 >
 > Right, I don't think one can assert a performance hit without
 > measurements supporting the idea.
 >
 >> TL;DR my objections are mostly based on pure architectural arguments,
 >> rather than practicality.
 >
 > Sure, that's reasonable, it's a matter of what you prefer.  That's
 > harder to take issue with than claims about performance.
 >
 >> I also don't like Python, PHP and Perl for those very same reasons -
 >
 > Those are at a totally different level than Forth, in terms of layers of
 > implementation and runtime libraries, overhead, etc.  It's better to
 > compare to something like C, or a hypothetical cleaned up version of C,
 > or even to Forth with locals ;).
A lot depends on how solid you want to make your implementation. I got locals in uBasic/4tH.
: exec_local                           ( --)
   [: get_exp 0 max 27 frame dup @ - + min negate cells frame + dup local <
   if E.MANYLOC throw else frame @ over ! to frame then ;]
   exec_function                        \ execution semantics for LOCALS()
;
This one reserves room for locals. You may use up to 26 locals per function since there are 26 letters in the alphabet (duh!).
: exec_param                           ( --)
   frame exec_local frame               \ allocate locals, save pointers
   begin over over > while cell+ (pop) over ! repeat drop drop
;
If the reserved room has to be initialized by the stack, it calls EXEC_LOCAL and then copies the values there.
: exec_return                          ( --)
   get_token paren? putback if ['] get_push exec_function then
   gpop prog ! frame dup local #local 1- cells + >
   if E.NOSCOPE throw ;then @ to frame
;
This one looks whether RETURN returns a value - and if it does, it pushes this value on the stack. Then it sets the return address. It checks for the sanity of the stack frame and if okay THEN it finally updates the stack pointer.
You comfortable left out the initialization of the stack frame. Agreed, if ALL values are transferred to the return stack the overhead is minimal. But how often happens that?
 > Those are at a totally different level than Forth, in terms of layers of
 > implementation and runtime libraries, overhead, etc.  It's better to
 > compare to something like C, or a hypothetical cleaned up version of C,
 > or even to Forth with locals ;).
True - but that's not the level of abstraction I'm considering. I think a language should have a well designed core, surrounded by a constellation of extensions. Like C with its standard library and Forth with its word sets. For comparison - C got a few dozen keywords. PHP got at least two different ways to extend binary extensions alone. A full Python installation is scattered all over the filesystem, so you got a hell of a job to extract a single, transferable application. Not to mention the awkward syntax (although they fixed some of it in v3). In Perl you always have to wonder which prefix is fashionable today.
Now, I won't say Forth doesn't have its issues. I think IN ESSENCE recognizers are a beautiful idea. Extend it to strings and you could eradicate "parsing words" and have something like:
"lib/mylib.4th" include
"Square" : "the square is:" print dup * cr ;
But okay, we'll do with what we have ;-) And BTW, TURNKEY should be standard. Clean up the dictionary, pump out an executable.
Hans Bezemer

Date Sujet#  Auteur
30 Aug 24 * Avoid treating the stack as an array [Re: "Back & Forth" is back!]142Buzz McCool
30 Aug 24 +* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]9minforth
31 Aug 24 i+- Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]1BuzzMcCool
2 Sep 24 i+* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]4Buzz McCool
3 Sep 24 ii`* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]3dxf
3 Sep 24 ii `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]2Buzz McCool
3 Sep 24 ii  `- Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]1dxf
11 Sep 24 i+* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]2minforth
11 Sep 24 ii`- Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]1Hans Bezemer
12 Sep 24 i`- Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]1dxf
31 Aug 24 `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]132dxf
31 Aug 24  `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]131BuzzMcCool
6 Sep 24   `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]130Buzz McCool
7 Sep 24    +* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]123Hans Bezemer
10 Sep 24    i`* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]122Paul Rubin
10 Sep 24    i +- Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]1dxf
11 Sep 24    i +* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]117dxf
11 Sep 24    i i`* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]116dxf
12 Sep 24    i i `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]115Paul Rubin
12 Sep 24    i i  +* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]98dxf
12 Sep 24    i i  i+* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]3minforth
12 Sep 24    i i  ii`* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]2mhx
12 Sep 24    i i  ii `- Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]1minforth
12 Sep 24    i i  i+* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]57Anton Ertl
13 Sep 24    i i  ii`* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]56dxf
13 Sep 24    i i  ii `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]55minforth
13 Sep 24    i i  ii  `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]54dxf
13 Sep 24    i i  ii   +* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]10Paul Rubin
13 Sep 24    i i  ii   i+* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]2Jan Coombs
13 Sep 24    i i  ii   ii`- Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]1Anton Ertl
13 Sep 24    i i  ii   i`* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]7dxf
14 Sep 24    i i  ii   i `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]6Paul Rubin
14 Sep 24    i i  ii   i  `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]5dxf
14 Sep 24    i i  ii   i   `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]4Paul Rubin
15 Sep 24    i i  ii   i    `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]3dxf
15 Sep 24    i i  ii   i     `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]2Paul Rubin
16 Sep 24    i i  ii   i      `- Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]1dxf
13 Sep 24    i i  ii   +- Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]1albert
13 Sep 24    i i  ii   `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]42Anton Ertl
14 Sep 24    i i  ii    `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]41dxf
14 Sep 24    i i  ii     +- Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]1minforth
14 Sep 24    i i  ii     `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]39Anton Ertl
14 Sep 24    i i  ii      +- Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]1dxf
15 Sep 24    i i  ii      `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]37Stephen Pelc
15 Sep 24    i i  ii       `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]36Anton Ertl
15 Sep 24    i i  ii        +* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]9Stephen Pelc
15 Sep 24    i i  ii        i+* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]7Paul Rubin
16 Sep 24    i i  ii        ii`* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]6Stephen Pelc
16 Sep 24    i i  ii        ii +- Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]1minforth
16 Sep 24    i i  ii        ii `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]4Anton Ertl
16 Sep 24    i i  ii        ii  `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]3mhx
16 Sep 24    i i  ii        ii   `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]2Anton Ertl
17 Sep 24    i i  ii        ii    `- Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]1mhx
16 Sep 24    i i  ii        i`- Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]1Anton Ertl
27 Sep 24    i i  ii        `* value-flavoured structures (was: Avoid treating the stack as an array)26Ruvim
27 Sep 24    i i  ii         +* Re: value-flavoured structures15minforth
27 Sep 24    i i  ii         i+- Re: value-flavoured structures1mhx
27 Sep 24    i i  ii         i`* Re: value-flavoured structures13Ruvim
27 Sep 24    i i  ii         i `* Re: value-flavoured structures12minforth
27 Sep 24    i i  ii         i  +* Re: value-flavoured structures8Ruvim
28 Sep 24    i i  ii         i  i+* Re: value-flavoured structures6Paul Rubin
28 Sep 24    i i  ii         i  ii+* Re: value-flavoured structures2dxf
28 Sep 24    i i  ii         i  iii`- Re: value-flavoured structures1Paul Rubin
28 Sep 24    i i  ii         i  ii`* Re: value-flavoured structures3albert
28 Sep 24    i i  ii         i  ii `* Re: value-flavoured structures2Paul Rubin
28 Sep 24    i i  ii         i  ii  `- Re: value-flavoured structures1Paul Rubin
28 Sep 24    i i  ii         i  i`- Re: value-flavoured structures1dxf
3 Oct 24    i i  ii         i  `* Re: value-flavoured structures3Anton Ertl
4 Oct 24    i i  ii         i   `* Re: value-flavoured structures2dxf
4 Oct 24    i i  ii         i    `- Re: value-flavoured structures1albert
3 Oct 24    i i  ii         `* Re: value-flavoured structures (was: Avoid treating the stack as an array)10Anton Ertl
4 Oct 24    i i  ii          `* Re: value-flavoured structures9Ruvim
4 Oct 24    i i  ii           `* Re: value-flavoured structures8Anton Ertl
4 Oct 24    i i  ii            `* Re: value-flavoured structures7Ruvim
4 Oct 24    i i  ii             `* Re: value-flavoured structures6Anton Ertl
5 Oct 24    i i  ii              `* Re: value-flavoured structures5Ruvim
5 Oct 24    i i  ii               `* Re: value-flavoured structures4Anton Ertl
6 Oct 24    i i  ii                +- value-flavoured properties of a word (was: value-flavoured structures)1Ruvim
6 Oct 24    i i  ii                +- value-flavoured approach (was: value-flavoured structures)1Ruvim
6 Oct 24    i i  ii                `- value-flavoured approach in API (was: value-flavoured structures)1Ruvim
14 Sep 24    i i  i`* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]37Anton Ertl
14 Sep 24    i i  i +* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]34Ahmed
14 Sep 24    i i  i i+* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]32Anton Ertl
14 Sep 24    i i  i ii`* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]31Ahmed
14 Sep 24    i i  i ii +- Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]1Ahmed
14 Sep 24    i i  i ii +* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]7Ahmed
14 Sep 24    i i  i ii i`* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]6mhx
14 Sep 24    i i  i ii i +* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]4Ahmed
15 Sep 24    i i  i ii i i`* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]3minforth
15 Sep 24    i i  i ii i i `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]2Ahmed
15 Sep 24    i i  i ii i i  `- Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]1Ahmed
15 Sep 24    i i  i ii i `- Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]1albert
15 Sep 24    i i  i ii `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]22dxf
15 Sep 24    i i  i ii  +* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]16Ahmed
15 Sep 24    i i  i ii  i`* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]15mhx
15 Sep 24    i i  i ii  i `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]14ahmed
16 Sep 24    i i  i ii  i  `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]13Ahmed
16 Sep 24    i i  i ii  i   `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]12mhx
16 Sep 24    i i  i ii  i    +- Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]1Ahmed
16 Sep 24    i i  i ii  i    +* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]3dxf
16 Sep 24    i i  i ii  i    i+- Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]1Ahmed
16 Sep 24    i i  i ii  i    i`- Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]1mhx
16 Sep 24    i i  i ii  i    `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]7Paul Rubin
15 Sep 24    i i  i ii  `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]5Paul Rubin
15 Sep 24    i i  i i`- Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]1albert
15 Sep 24    i i  i `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]2dxf
12 Sep 24    i i  `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]16Anton Ertl
11 Sep 24    i `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]3Hans Bezemer
8 Sep 24    `* Re: Avoid treating the stack as an array [Re: "Back & Forth" is back!]6Stephen Pelc

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal