Sujet : Re: portable or not? Volatile strings
De : do-not-use (at) *nospam* swldwa.uk (Gerry Jackson)
Groupes : comp.lang.forthDate : 12. Aug 2024, 12:36:18
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v9cs3g$38jvi$1@dont-email.me>
References : 1 2 3
User-Agent : Mozilla Thunderbird
On 12/08/2024 10:01,
albert@spenarnc.xs4all.nl wrote:
In article <v9cfp9$364en$1@dont-email.me>,
Ruvim <ruvim.pinka@gmail.com> wrote:
is way?
>
>
Strings that are stored relatively to the HERE address may become
invalid after:
- a definition is created via a defining word;
- definitions are compiled with : or :NONAME;
- data space is allocated using ALLOT, `,` (comma),
`C,` (c-comma), or ALIGN.
— as "3.3.3.6 Other transient regions"
Not relevant. My "transient" region is permanent. That I have
permission to invalidate doesn't affect me.
<https://forth-standard.org/standard/usage#usage:transient> says.
>
All affected transition regions shall be listed. If a region is not
listed as affected, than it is not affected by allocating data space memory.
My regions are not affected. So again this is not relevant.
>
>
The section "11.3.4 Other transient regions"
<https://forth-standard.org/standard/file#file:buffers> says:
>
| The system provides transient buffers for S" and S\" strings.
| These buffers shall be no less than 80 characters in length,
| and there shall be at least two buffers. The system should be
| able to store two strings defined by sequential use of
| S" or S\". RAM-limited systems may have environmental
| restrictions on the number of buffers and their lifetimes.
A permanent buffer can count as transient.
>
>
Since this doesn't say that the buffer my become invalid after some
memory allocation, the buffer shall not become invalid after any memory
allocation (by default).
That is putting restriction to my buffer.
>
In the same time, a Forth system is allowed to limit the buffer lifetime
(for example, till the next memory allocation), and document it as an
environmental restriction.
Lots of talk of whether the buffers become invalid.
My buffers never become invalid. That is not the point.
The standard talks about transient region. My regions are permanent
and there are other ways to handle S" , say by using ALLOCATE.
To call a region transient and then restrict how transient they are,
make a region not really temporary. So in this respect I am in the clear.
Note that as S" is in a definition, the string is bound to be permanent.
So I think the program is not portable, because what I do is perfectly
legal.
I can't make out what you think.
>
[ It was sufficient to replace S" with S"' in order to make it run:
: S"' &" PARSE ;
]
Okay let's say it out loud. Classic Forth is not fit for handling strings.
A denotation that generates a constant string "blablabla" that has
a status as a number is long overdue.
The mindset of formulating standards is so 70's.
Yes, transient regions are another Forth anachronism from the early days of Forth when memory was scarce and expensive. In my system all transient regions are permanent so I don't worry about them getting corrupted. The standard ought to be updated to make them permanent or make provision for the user to allot or allocate them.
-- Gerry