Sujet : Re: portable or not? Volatile strings
De : ruvim.pinka (at) *nospam* gmail.com (Ruvim)
Groupes : comp.lang.forthDate : 12. Aug 2024, 09:28:27
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v9ch3d$364en$2@dont-email.me>
References : 1
User-Agent : Mozilla Thunderbird
On 2024-08-11 17:35,
albert@spenarnc.xs4all.nl wrote:
I come across a tetris game, and there were bricks defined in
this way:
: DEF-BRICK CREATE 4 0 DO
' EXECUTE 0 DO DUP I CHARS + C@ C, LOOP DROP
REFILL DROP
LOOP
DOES> ROT 4 * ROT + 2* CHARS + ;
DEF-BRICK BRICK1 S" "
S" ###### "
S" ## "
S" "
Apparently the data field of bricks are filled in some mysterious
way by DEF-BRICK but that is not the subject.
It does some parsing from the input stream, which is kind of
tricky. As REFILL is not present in lina's core, you must
do "-traditional- WANTED" , but that still is not the issue.
I made S" " such that it ALLOT's the string at HERE,
This is not allowed, without any options.
The alloted data space regions shall be contiguous unless "definitions are added to or removed from the dictionary between allocations" (3.3.3.2), or the function of `INCLUDED` is performed (11.6.1.1718, 11.6.2.1714). No other conditions are mentioned anywhere.
to prevent problems with going out of scope, even in interpret mode.
(Only 256,000,000,000 -10 bytes left).
This doesn't sit well with the definition of BRICK1 ,
that sees its data area grabbed.
You are probably not surprised that tetris doesn't work.
The question is, is it legal to store these temporary strings
in the dictionary in this way?
[ It was sufficient to replace S" with S"' in order to make it run:
: S"' &" PARSE ;
]
-- Ruvim