• Re: value-flavoured structures (was: Avoid treating the stack as an arr

    From Anton Ertl@21:1/5 to Ruvim on Thu Oct 3 15:58:58 2024
    Ruvim <ruvim.pinka@gmail.com> writes:
    On 2024-09-15 20:16, Anton Ertl wrote:
    A major merit for value-flavoured structures is that you can change
    the field size (e.g, from 1 byte to 2 bytes or vice versa) without
    changing all the code accessing those fields. That's independent of
    cell size.

    Yes, you can change the field size, but only as far as its value
    occupies the same number of a stack items and the stack is the same.

    Yes. But you can switch between different sizes that all fit into a
    cell, or between different memory sizes of floats without changing the
    rest of the code.

    Similar for the word `to` - `to` applies to the words created with
    `value`, `fvalue`, `2value`. But the source code around `to foo` (and
    `foo`) depends on the kind of `foo`, so the kind of `foo` cannot be
    changed without changing the source code around where it is used.

    That's just as for reading the value-flavoured field; if a field
    pushes one cell, TO to the field also consumes one cell; likewise for
    float fields.

    - 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 2024: https://euro.theforth.net

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