Deutsch   English   Français   Italiano  
<vvsk2k$127bb$1@dont-email.me>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: Stephen Pelc <stephen@vfxforth.com>
Newsgroups: comp.lang.forth
Subject: Re: ADDRESSABLE: value-flavoured words
Date: Mon, 12 May 2025 10:55:16 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 55
Message-ID: <vvsk2k$127bb$1@dont-email.me>
References: <2025May12.094032@mips.complang.tuwien.ac.at>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=fixed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 12 May 2025 12:55:16 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="829fa815f25da0475c211fb0a23952b3";
	logging-data="1121643"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1+NTnPunOp1+rZnqmNHH/Iz"
User-Agent: Usenapp for MacOS
Cancel-Lock: sha1:tIMJ2pKYrcdeEjyMAZ1VNh98TOs=
X-Usenapp: v1.27.4/l - Full License
Bytes: 3088

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.

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. Here
are two examples of local buffer use. Both are taken from the VFX Forth
kernel and demonstrate convenience for operating system
Interfacing.

Local buffers are defined using a trailing '[' character at the end of
local variable name, e.g.
  IOBUFF[ cell ]
followed by the buffer size and a trailing '] '

NXCALLx is a call to a shared library function:
px ... p1 address NXCALLx  \ x=#parameters, address = function entry
NXCALL is a low level integer function used before the EXTERN:
interface has been compiled.

\ int chmod(const char *path, mode_t mode);
: (OS_Chmod)    { c-addr u mode | zaddr[ #1024 ] -- ior }
  c-addr u zaddr[ zplace
  zaddr[ mode  dll_chmod @ nxcall2
  0=
;

: (OS_Key)    \ -- key
  { | iobuff[ cell ] -- char }
  ?PrepTerm
  stdin @ iobuff[ 1  dll_ReadFile @ nxcall3 drop
  iobuff[ c@
;

All VFX Forth downloads include the source code.

Stephen