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 : 24. Aug 2024, 11:10:57
Autres entêtes
Organisation : KPN B.V.
Message-ID : <nnd$7a20fb9c$61ca75f1@52dd296416997ca8>
References : 1 2 3 4
User-Agent : trn 4.0-test77 (Sep 1, 2010)
In article <66c94c52$1@news.ausics.net>, dxf  <dxforth@gmail.com> wrote:
On 22/08/2024 8:59 pm, albert@spenarnc.xs4all.nl wrote:
In article <nnd$274f6c32$10db022f@ea48fe6bf4bc59ed>,
Hans Bezemer  <the.beez.speaks@gmail.com> wrote:
On 13-08-2024 06:07, dxf wrote:
On 13/08/2024 5:34 am, albert@spenarnc.xs4all.nl wrote:
...
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>  ... ;
>
OTOH it's no less difficult to write...
>
: M"  [CHAR] " PARSE  HERE  OVER ALLOT  SWAP MOVE ;
>
: DEF-BRICK  CREATE  DOES>  ROT 4 * ROT + 2* CHARS + ;
>
DEF-BRICK BRICK1         M"         "
                          M" ######  "
                          M"   ##    "
                          M"         "
>
>
In 4tH, the easiest solution would be:
>
: BRICK@ ROT + @C SWAP 2* CHARS + ;
>
CREATE BRICK1
  ,"         "
  ," ######  "
  ,"   ##    "
  ,"         "
DOES> BRICK@ ;
>
I dislike the use of parsing here by ," . It happens to work
because ," doesn't destroy the concatenation of HERE.
So you couldn't check the solution without digging into the 4TH
documentation.
>
In these case parsing is more or less advantageous because it allows
easier represent the bricks. The introduction of an auxiliary word M"
that is easily understood and checked is far superior using ," .
...
>
For the general case that's true.  OTOH 4tH is free to exploit what it has.
The original ANS-Forth version tried using S" but it got complicated due
to the dual-action word.  If standard compliance is the goal then options
are limited.  OTOH a Gforth user not caring about compliance could exploit
what he had and define things more succinctly:
>
 : M"  \"-parse mem, ;
>
(assuming he knew these words existed)

I accept the use of non standard words if there is an advantage for it.
In this case a small change keeps the program totally standard,
at the same time allowing to escape confusion over allocation
situations and having it run on a ciforth 10% of the complexity of
gforth.

I occasionally promote ciforth techniques, if they are substantially
simpler and standard programs look akward in comparison.

Probably mem, is the same as my
: ,, HERE SWAP DUP ALLOT MOVE ;

Groetjes Albert
--
Temu exploits Christians: (Disclaimer, only 10 apostles)
Last Supper Acrylic Suncatcher - 15Cm Round Stained Glass- Style Wall
Art For Home, Office And Garden Decor - Perfect For Windows, Bars,
And Gifts For Friends Family And Colleagues.

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