Sujet : Re: value-flavoured structures (was: Avoid treating the stack as an array)
De : anton (at) *nospam* mips.complang.tuwien.ac.at (Anton Ertl)
Groupes : comp.lang.forthDate : 03. Oct 2024, 16:58:58
Autres entêtes
Organisation : Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID : <2024Oct3.175858@mips.complang.tuwien.ac.at>
References : 1 2 3 4 5 6 7
User-Agent : xrn 10.11
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.htmlcomp.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