• Re: Stack notation (was: d/dx in forth)

    From Anton Ertl@21:1/5 to Ruvim on Wed May 29 16:46:20 2024
    Ruvim <ruvim.pinka@gmail.com> writes:
    On 2024-05-24 15:56, Anton Ertl wrote:
    melahi_ahmed@yahoo.fr (Ahmed) writes:

    In Forth it is a bit messier because you
    want a signature like


    : d/dx ( xt -- xt ) .... ;

    Most probably he meant ( xt1 -- xt2 )



    Do you mean that ( xt -- xt ) is an incorrect stack diagram for this case?

    To me (and to vmgen) ( xt -- xt ) describes a word that expects an xt
    on the data stack but does not change the data stack at all.

    If two items in the stack effect comment have the same name (such as
    in this case), they have the same value. That's also the usage in the standard:

    | 6.1.1290 DUP dupe CORE
    | ( x -- x x )
    |
    | R@ r-fetch CORE
    | ...
    | Execution:
    | ( -- x ) ( R: x -- x )

    I always thought that such use is correct. Because formally "xt"
    (without an index) only denotes the data type, not a data value.

    Says who?

    My usage and the usage in the standard is that if there are two
    different items with the same type, they get two different names,
    e.g., by adding a digit. And if there is only one item of that type
    (as in R@), there is no need to distinguish it from itself by adding a
    digit.

    In a stack diagram, the same data type symbols with the same indices
    usually denote the same data value. Otherwise, if data values are not >mentioned (like "0", "-1", etc), it is unknown from the stack diagram
    where the values are the same. Since different symbols in the does not
    mean different data values.

    No, but the same name means that they are the same value.

    For example "abs ( n -- +n )" — in some
    cases the data values "before" and "after" are the same.

    The standard has:

    | ABS abs CORE
    | ( n -- u )

    So we don't know whether the standard considers "+n" to be the same
    name or a different name from "n".

    - anton
    --
    M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
    comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
    New standard: https://forth-standard.org/
    EuroForth 2023: https://euro.theforth.net/2023

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)