Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #135021

Re: The joy of formatting

Newsgroups comp.lang.forth
References <nnd$7b365bf7$7124ac52@50f873c72dd8fb98> <69f2ba42$1@news.ausics.net>
From albert@spenarnc.xs4all.nl
Subject Re: The joy of formatting
Message-ID <nnd$0ff0e8c8$058d7ad7@15d7ec6ab0bb7dfb> (permalink)
Organization KPN B.V.
Date 2026-04-30 11:06 +0200

Show all headers | View raw


In article <69f2ba42$1@news.ausics.net>, dxf  <dxforth@gmail.com> wrote:
>On 29/04/2026 11:41 pm, albert@spenarnc.xs4all.nl wrote:
>> Formerly I had this clunky handling of colors.
>> ...
>> Now if you have FORMAT this becomes a lot less clunky.
>
>I agree the original was clunky.  But whether FORMAT was necessary,
>I'm less certain.  Naturally, I'm too lazy to show an alternative.
>But I can for your last example, as I'm sure can others ...
>
>> : default-bw "%e [00m" FORMAT TYPE ;
>
>: default-bw ." \1b[00m" ;
>

You don't realize that FORMAT makes escapes in strings
superfluous. It is a loadable alternative that is not
intrusive unlike escapes in strings, that are forever contraversial.
Follow the c-crowd for escapes? Or the FORTRAN crowd?
Add it to the Forth standard? If you do that you irreversibly
complicate the Forth kernel and add another bone of contention
in the mix.

Once you embrace `` $@ $! $+! $C+ $/ $\ '' string packet,
FORMAT is just one screen.
If you don't want it, you don't load it.

--------------------------------------------------------
( FORMAT FORMAT&EVAL .FORMAT )          \ AH&CH C2feb15
DATA CRS$ 4096 ALLOT \   ":2" WANTED
NAMESPACE FORMAT-WID           FORMAT-WID DEFINITIONS
: d S>D 0 (D.R) CRS$ $+! ;  \ Add INT as a string.
: s CRS$ $+! ;  : c CRS$ $C+ ;  \ Add a STRING / CHAR as such.
: n ^J c ;   : r ^M c ; : e 27 c ; \ Add single char's
PREVIOUS DEFINITIONS
\ Format the first part of STRING, up till %, leave REST.
: _plain    &% $/ CRS$ $+! ;
\ Format X with first word of STRING, up till BL, leave REST.
: _format   BL $/ 2SWAP >R >R 'FORMAT-WID >WID (FIND) NIP NIP
    DUP 0= 51 ?ERROR EXECUTE R> R> ;
\ Format X1 .. Xn using the format STRING.
: FORMAT 0 CRS$ ! BEGIN DUP WHILE _plain DUP IF _format THEN
    REPEAT 2DROP CRS$ $@ ;
: FORMAT&EVAL   FORMAT EVALUATE ;   : .FORMAT FORMAT TYPE ;
--------------------------------------------------------

Once FORMAT is present, simple oo is two screens (actually
one screen, the other is another universal tool.)
Escaped strings doesn't help with defining oo.
-- 
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.

Back to comp.lang.forth | Previous | NextPrevious in thread | Next in thread | Find similar


Thread

The joy of formatting albert@spenarnc.xs4all.nl - 2026-04-29 15:41 +0200
  Re: The joy of formatting dxf <dxforth@gmail.com> - 2026-04-30 12:11 +1000
    Re: The joy of formatting Hans Bezemer <the.beez.speaks@gmail.com> - 2026-04-30 09:48 +0200
    Re: The joy of formatting albert@spenarnc.xs4all.nl - 2026-04-30 11:06 +0200
      Re: The joy of formatting Hans Bezemer <the.beez.speaks@gmail.com> - 2026-04-30 23:34 +0200
    Re: The joy of formatting albert@spenarnc.xs4all.nl - 2026-04-30 11:11 +0200
      Re: The joy of formatting dxf <dxforth@gmail.com> - 2026-04-30 23:58 +1000
        Re: The joy of formatting albert@spenarnc.xs4all.nl - 2026-04-30 18:11 +0200
          Re: The joy of formatting dxf <dxforth@gmail.com> - 2026-05-01 09:57 +1000
            Re: The joy of formatting anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-05-01 06:03 +0000
              Re: The joy of formatting dxf <dxforth@gmail.com> - 2026-05-03 23:09 +1000
                Re: The joy of formatting anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2026-05-03 14:11 +0000
                Re: The joy of formatting dxf <dxforth@gmail.com> - 2026-05-04 11:02 +1000
      Re: The joy of formatting minforth <minforth@gmx.net> - 2026-04-30 20:47 +0200
        Re: The joy of formatting Krishna Myneni <krishna.myneni@ccreweb.org> - 2026-05-03 09:07 -0500

csiph-web