Sujet : Re: ADDRESSABLE: value-flavoured words
De : anton (at) *nospam* mips.complang.tuwien.ac.at (Anton Ertl)
Groupes : comp.lang.forthDate : 12. May 2025, 17:47:33
Autres entêtes
Organisation : Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID : <2025May12.184733@mips.complang.tuwien.ac.at>
References : 1 2
User-Agent : xrn 10.11
Stephen Pelc <
stephen@vfxforth.com> writes:
On 12 May 2025 at 09:40:32 CEST, "Anton Ertl" <Anton Ertl> wrote:
>
Programmers use value-flavoured words for various reasons. In some
cases they want to have the address of the data otherwise accessed by
calling the value-flavoured word V or by using TO V. Popular systems
have ADDR V or &OF V for taking the address.
However, taking the address of the data means that (in the absence of
complicated, expensive, and unreliable alias analysis) any memory
access can access the data, so we are very limited in
register-allocating the data and/or in reordering the accesses to the
data.
>
VFX Forth and other MPE/W&P Forths have had ADDR for decades.
>
I think that there two flaws in the argument above
1) The use of ADDR or &OF is quite rare and often specialised,
2) All uses that require ADDR can be satisfied using a buffer.
My use of ADDR has significantly reduced over the last ten years.
Sure you can use a variable-flavoured word instead of a
value-flavoured word, and you could do that already before VALUE was
invented (and long before ADDR/&OF was invented). Yet you have
introduced ADDR, SwiftForth has introduced &OF, and despite my
arguments against, Gforth 1.0 will introduce ADDR and &OF. You may be
right that ADDR is not needed, but do you take the consequence and
remove ADDR from VFX?
Looking at SwiftForth, I see that all occurences of &OF have to do
with defining &OF, i.e., there is not a single use of &OF for getting
the address of a piece of data.
In any case, the point of my posting is not to promote ADDR, but to
point out how we can avoid the negative repercussions of the existence
of ADDR for value-flavoured words on which ADDR is actually not used.
I would propose that a more satidfying solution is to add local
buffers, which are decades old in MPE/W&P Forths. MPE uses
a notation that others object to for local buffers, but AFAIR someone
had a good notation and implementation that was published.
Gforth (development) has implemented the MPE syntax for local buffers
for several years:
: foo ( n -- n1 )
{: | n[ cell ] :}
n[ ! 1 n[ +! n[ @ ;
3 foo . \ prints 4
Gforth has also had variable-flavoured locals since 1994. You can
write FOO with a variable-flavoured local as follows:
: foo {: w^ n -- n1 :}
1 n +! n @ ;
Why did you mention local buffers? My guess is that the reason is
that for all value-flavoured words other than locals, every Forth has
a variable-flavoured counterpart, so you pointed out your way of
defining variable-flavoured locals, which completes the set for your
systems. But ADDR/&OF was not just introduced for locals, so on each
system that implements ADDR/&OF somebody thought that telling the
customer to use a variable-flavoured word instead is not good enough.
- 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 2023 proceedings: http://www.euroforth.org/ef23/papers/EuroForth 2024 proceedings:
http://www.euroforth.org/ef24/papers/