Re: portable or not? Volatile strings

Liste des GroupesRevenir à cl forth 
Sujet : Re: portable or not? Volatile strings
De : albert (at) *nospam* spenarnc.xs4all.nl
Groupes : comp.lang.forth
Date : 12. Aug 2024, 20:34:31
Autres entêtes
Organisation : KPN B.V.
Message-ID : <nnd$43b12c93$7f618144@18dd570284c2b77b>
References : 1 2 3 4
User-Agent : trn 4.0-test77 (Sep 1, 2010)
In article <v9crjs$364en$5@dont-email.me>,
Ruvim  <ruvim.pinka@gmail.com> wrote:
On 2024-08-12 13:31, albert@spenarnc.xs4all.nl wrote:
In article <v9ch3d$364en$2@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,
>
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.
>
That settles it. Note that it applies to interpret mode only,
during a definition being permanent is not an issue because it is in a
definition.
This is a defect ("bug") in S" in ciforth.
>
The only solution is to make S" state smart:
: S" STATE @ IF POSTPONE " ELSE &" PARSE ;  IMMEDIATE
>
This implementation implies an environmental restriction: the string
returned by the interpretation semantics of `S"` is valid until a
subsequent invocation of `REFILL`, because the returned string is
located in the input buffer.

Remember ciforth is not only "computer intelligence Forth"
it is also "close to iso forth", cutting corners for simplicity.
There is no REFILL in ciforth, all files are slurped.

In my lisp , manx , ciasdis I never needed REFILL.
In the above tetris example, this S" works with REFILL.

I implemented REFILL in the library. Dutch Forth Users wanted
that.
For each nested include you need a separate buffer for each file.
Fortunately the block/screen buffers can serve because they have a
lock/unlock state.
Still it was a pain, and you have to carefully load all facilities
belonging to a -traditional- expansion at the same time,
because you probably need WORD FIND .
7 blocks have to be loaded,

In the presence of REFILL I have to load the ALLOCATE wordset
and follow $" PARSE with $MAKE-PERMANENT or some such.

But ... the code becomes better without REFILL.

In my book the code should be

                        "        "
                        "######  "
                        "  ##    "
                        "        "
DEF-BRICK BRICK1

Instead of

DEF-BRICK BRICK1        S"         "
                        S" ######  "
                        S"   ##    "
                        S"         "

The code (untested) could be
: DEF-BRICK CREATE
    2>R 2>R 2>R 2>R
    2R> ,, 2R> ,, 2R> ,, 2R> ,,
 DOES>  ... ;

More Forth like. First data then creation of a structure with it.
More readable code. No brain twisting REFILL where the first word
is looked up in the dictionary via ' .

At the expense of storing the strings two times in the dictionary.
(I know most Forthers really get sick by the idea alone.)

>
>
[ Before it was an alias for the "-as-a-prefix without the
prefix flag.
: S" POSTPONE " ; IMMEDIATE
>
In this implementation the interpretation semantics are incorrect, right?

Right. S" aap" does the same as "aap" storing the string at HERE.
The former finds `` S" '' in the dictionary, the latter `` " ''
found as a prefix. S"aap" is not found, because S" is not marked
PREFIX.

>
>
It sticks to the design rule for ciforth that only denotations,
generalisation of numbers, are allowed to be state smart. ]
>
>
>
--
Ruvim
>
NOTE:
: ,, HERE   SWAP   DUP   ALLOT   MOVE ;
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat purring.            - the Wise from Antrim -

Date Sujet#  Auteur
12 Aug 24 * Re: portable or not? Volatile strings8Ruvim
12 Aug 24 `* Re: portable or not? Volatile strings7Ruvim
12 Aug 24  `* Re: portable or not? Volatile strings6albert
13 Aug 24   `* Re: portable or not? Volatile strings5dxf
21 Aug 24    `* Re: portable or not? Volatile strings4Hans Bezemer
22 Aug 24     `* Re: portable or not? Volatile strings3albert
24 Aug 24      `* Re: portable or not? Volatile strings2dxf
24 Aug 24       `- Re: portable or not? Volatile strings1albert

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal