Re: portable or not? Volatile strings

Liste des GroupesRevenir à cl forth 
Sujet : Re: portable or not? Volatile strings
De : ruvim.pinka (at) *nospam* gmail.com (Ruvim)
Groupes : comp.lang.forth
Date : 12. Aug 2024, 12:00:53
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <v9cq17$364en$4@dont-email.me>
References : 1 2 3
User-Agent : Mozilla Thunderbird
On 2024-08-12 13:01, albert@spenarnc.xs4all.nl wrote:
In article <v9cfp9$364en$1@dont-email.me>,
Ruvim  <ruvim.pinka@gmail.com> wrote:
On 2024-08-11 17:35, albert@spenarnc.xs4all.nl wrote:
[...]
I made S" " such that it ALLOT's the string at HERE, 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?
>
>
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.
Yes, this is not relevant to your case, but this is correct by itself.
Then I realized irrelevance and made another post.

 
<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.
There is no need to repeat this.
[...]

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.
[...]

I can't make out what you think.
A possible implementation for the interpretation semantics for `S"` is to keep data somewhere in the memory region that returns by "here unused", and declare the lifetime restriction for the returned string.
For example:
   128 constant _sbufsize
   0 value _sn
   4 value _snlimit
   : _sbuf-next ( -- c-addr u )
     here aligned 4096 +  _sbufsize _sn * + _sbufsize
     ( c-addr.buf u.buf-len )
     2dup + here unused + u> if -8 throw then \ "dictionary overflow"
     _sn 1+ _snlimit mod to _sn
   ;
   : _memorize-string ( c-addr1 u -- c-addr2 u )
     >r _sbuf-next r@ u< ( c-addr c-addr.buf flag )
     if -18 throw then \ "parsed string overflow"
     r@ over >r chars move  r> r>
   ;
   : s" ( -- c-addr u | )
     '"' parse compilation if slit, exit then _memorize-string
   ; immediate
At first I thought you were asking about this approach.
This approach implies an environmental restriction.

 
>
[ 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.
 
Why not prepare a proposal?
--
Ruvim

Date Sujet#  Auteur
12 Aug 24 * Re: portable or not? Volatile strings14Ruvim
12 Aug 24 `* Re: portable or not? Volatile strings13albert
12 Aug 24  +- Re: portable or not? Volatile strings1Ruvim
12 Aug 24  +- Re: portable or not? Volatile strings1Gerry Jackson
13 Aug 24  `* Re: portable or not? Volatile strings10mhx
14 Aug 24   +* Re: portable or not? Volatile strings2dxf
14 Aug 24   i`- Re: portable or not? Volatile strings1mhx
14 Aug 24   `* Re: portable or not? Volatile strings7Anton Ertl
14 Aug 24    `* Re: portable or not? Volatile strings6Gerry Jackson
14 Aug 24     `* Re: portable or not? Volatile strings5mhx
14 Aug 24      `* Re: portable or not? Volatile strings4minforth
15 Aug 24       `* Re: portable or not? Volatile strings3dxf
15 Aug 24        `* Re: portable or not? Volatile strings2albert
16 Aug 24         `- Re: portable or not? Volatile strings1dxf

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal