🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.forth
Article #281

Re: $trings

#281
From: albert
Date: Thu, 03 Dec 2026 10:18
94 lines
4664 bytes
In article <11epcob$35ubv$1@dont-email.me>,
Hans Bezemer  <the.beez.speaks@gmail.com> wrote:
>On 01-12-2026 09:09, Anton Ertl wrote:
>> Forthunately, the designers of Forth-94 already recognized this over
>> three decades ago, and focussed on the c-addr u representation, with
>> only a few words existing for dealing with the counted-string legacy.
>>
>>> With great pleasure I see that Gforth has adopted the use of a cell
>>> to store the count of a string, officially.
>>> $@ replaces COUNT.
>>
>> Not really, as explained below.
>>
>>> $! has no equivalent in brain damaged strings
>>
>> Exactly.
>>
>> The $tring implementation differs from COUNTed strings in more than
>> just the count size.
>
>Well, it's a beautiful day, let's start another flame war over strings.
>Because, although everyone still curses "counted strings", it's the only
>accepted "standard". You know, the only words you need for a string are:
>1. COUNT;
>2. PLACE;
>3. +PLACE.

This is equivalent to
gforth $@ $! $+!
ciforth $@ $! $+!

If you like the gforth approach to dynamically allocate the storage
you could do so, as can be done in ciforth.
>
>And it's easy to prove -- they're the only words I got and it works
>FINE! Okay, if you really want to may be a word like C>S to convert a
>character to a valid string. But that's it. And it works for all well
>designed Forth programs.
No argument here. You could extend e.g
: $C+ >R C>S R> $+! ;
and $/ , but these basic are really useful, with or without
dynamic allocation.
>
>And how did I do that? Simply by abstracting the whole thing. As long as
>you don't use COUNT to increment a string pointer and fetch the next
>character -- but simply return the string in addr/u form, we're fine --
>no matter how your string is formed.
>
>We could have arranged that ages ago. Fortunately, you didn't use S@, S!
>and S+! - because I'd very much like to see an abstracted string design,
>where all the schools are united -- no matter whether they use counted
>strings with a character, counted strings with a cell, ASCIIZ characters
>(like little me), counted ASCIIZ strings with a character or counted
>ASCIIZ strings with a cell, we're finally all brothers. We can use S!
>and can be assured our addr/u string is securely saved -- no matter what
>hides under the hood.

Totally agree.

>
>Because -- no matter how much I love addr/u, under ANS-Forth (or its
>2012 variant), there is still no standard way to store a string. Unless
>you want to get your hands very, very dirty.

Or unless you can extend the standard thirty years overdue.

>
>Note I *really* have no problem. I've used ASCIIZ strings since 4tH's
>inception -- for the very simple reason 4tH has a tight connection with
>C. Now, you're free to condemn ASCIIZ strings till kingdom come, but for
>me it has worked fine. COUNT returns *EXACTLY* what is required, so I
>have no problem (PLACE and +PLACE aren't defined in ANS-Forth -- so I
>can pretty much do what I want).

You could under the hood end all strings with asciz. You have to
only to document that "the buffer is supposed to be CELL+len+0" .
Or "don't worry my dynamic allocation takes care of everything".

>
>But what amazes me is that after fifty years people still lose URLs in
>counted strings. I mean -- can't we really define a lousy three words
>and make everyone happy?
>
>And again -- I'm not saying that for me. I fired my shot and it went out
>like a candle in the night. And I don't have no problem -- as I stated.
>Things are fine. Forthers must REALLY love their problems! :-)
>
>Hans Bezemer

Groetjes Albert
-- 
The Chinese government is satisfied with its military superiority over USA.
The next 5 year plan has as primary goal to advance life expectancy
over 80 years, like Western Europe.
Technical Details
Message-ID: <nnd$16d19594$06e5d23c@e0ac324802152f4d>
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!abo004.abavia.com!feed.abavia.com!abr001.abavia.com!abp002.abavia.com!reseller!not-for-mail
References: <nnd$2790af4d$71f56696@06eb3ea8c34cc53c> <2026Dec1.090920@mips.complang.tuwien.ac.at> <11epcob$35ubv$1@dont-email.me>

Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.forth
References: <nnd$2790af4d$71f56696@06eb3ea8c34cc53c> <2026Dec1.090920@mips.complang.tuwien.ac.at> <11epcob$35ubv$1@dont-email.me>
From: albert@spenarnc.xs4all.nl
Subject: Re: $trings
X-Newsreader: trn 4.0-test77 (Sep 1, 2010)
Originator: albert@cherry.(none) (albert)
Message-ID: <nnd$16d19594$06e5d23c@e0ac324802152f4d>
Organization: www.abavia.com
Date: Thu, 03 Dec 2026 11:18:53 +0100
Path: mbox-mo1.pugleaf.net!news-wdc.pugleaf.net!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!abo004.abavia.com!feed.abavia.com!abr001.abavia.com!abp002.abavia.com!reseller!not-for-mail
Lines: 95
Injection-Date: Thu, 03 Dec 2026 11:18:53 +0100
Injection-Info: reseller; mail-complaints-to="abuse@abavia.com"