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


Groups > comp.lang.forth > #134189

Re: 0 vs. translate-none

Newsgroups comp.lang.forth
References <2025Sep17.185305@mips.complang.tuwien.ac.at> <2025Sep21.145014@mips.complang.tuwien.ac.at> <nnd$3a917196$3672ddf3@dc5d361c73d4965c> <2025Sep22.085631@mips.complang.tuwien.ac.at>
From albert@spenarnc.xs4all.nl
Subject Re: 0 vs. translate-none
Message-ID <nnd$1341c3be$3cdffd65@4064d140883f035e> (permalink)
Organization KPN B.V.
Date 2025-09-22 10:09 +0200

Show all headers | View raw


In article <2025Sep22.085631@mips.complang.tuwien.ac.at>,
Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
<SNIP>
>>Only after the word is found, a prefix is handled differently, compare
>>immediate words. Such lookup is probably even less effort.
>
>My understaning is that if the user types
>
>123456789
>
>into the text interpreter, your text interpreter will search for
>
>123456789
>12345678
>1234567
>123456
>12345
>1234
>123
>12
>1
>
>and fail at the first 8 attempts, and finally match the ninth, and
>only then try to convert the string into a number.  By contrast, with
>recognizers, every recognizer (including REC-NAME) only has to deal
>with the full string, and most other recognizers have simpler and
>cheaper checks than REC-NAME.

No. 123456789 is looked up in the Forth wordlist, fails, then in the
minimum search wordlist.

'   &   ^   0   1   2   3   4   5   6   7
8   9   -   +   "   FORTH

1234556789 matches the prefix 1. Then 1 does its thing,
recognizes the number, and decides to leave it on the stack or
compile code for it. Isn't that smart? (or is it the way Forth
works from day one?)

>
>>Assume we have a PREFIX $ for hex.
>>Think of a unix environment, where $ is used for environment variables
>>and we want 0x for hex.
>>
>>NAMESPACE unix  \ That is VOCABULARY with a built-in ALSO
>>unix DEFINITIONS
>>' $ ALIAS 0x
>>
>>\ Warning: is not unique.
>>: $ PARSE-NAME GET-ENV POSTPONE DLITERAL ;  IMMEDIATE PREFIX
>>
>>...
>>...
>>PREVIOUS DEFINITIONS
>>As soon as you kick unix out of the search order, $ is again the
>>prefix for hex and 0xCD is no more recognized.
>
>Gforth has REC-ENV and that is active by default, and there is usually
>no reason to eliminate it from the system recognizer sequence.  You
>write ${HOME}.

Does that invalidate the example?

>
>>P.S. GET-ENV leaves a double. Adding POSTPONE DLITERAL makes that
>>$XXXX can be used in compilation mode.
>
>It seems that your approach embraces state-smartness.  By contrast,
>one benefit of recognizers is that they make it unnecessary to use
>words like S" or TO that often are implemented as state-smart words,
>or require unconventional mechanisms to avoid that.

No I don't. Numbers have always been state-smart, although you
won't admit to it.
In my system you can't postpone numbers, so that cannot lead to
problems. "AAP" is recognized but
POSTPONE "AAP"
POSTPONE 12345
is rejected.
So "AAP" is a generalised number and share the property that it
may be state-smart but like numbers there are no evil consequences.
Not by clever planning, but by sound design.

P.S. I don't intend to present or defend PREFIX as an alternative to
the recognizer proposals, but it is more sound than people think.
Also it is lean, so advantageous for vintage systems.

>
>- anton

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.

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


Thread

0 vs. translate-none anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-09-17 16:53 +0000
  Re: 0 vs. translate-none minforth <minforth@gmx.net> - 2025-09-19 12:24 +0200
    Re: 0 vs. translate-none anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-09-19 15:45 +0000
      Re: 0 vs. translate-none peter <peter.noreply@tin.it> - 2025-09-19 19:39 +0200
        Re: 0 vs. translate-none anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-09-20 07:25 +0000
          Re: 0 vs. translate-none peter <peter.noreply@tin.it> - 2025-09-20 10:34 +0200
            Re: 0 vs. translate-none anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-09-20 16:08 +0000
              Re: 0 vs. translate-none peter <peter.noreply@tin.it> - 2025-09-20 19:08 +0200
                Re: 0 vs. translate-none anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-09-20 17:57 +0000
                Re: 0 vs. translate-none peter <peter.noreply@tin.it> - 2025-09-20 20:55 +0200
                Re: 0 vs. translate-none anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-09-21 12:33 +0000
                Re: 0 vs. translate-none peter <peter.noreply@tin.it> - 2025-09-21 18:39 +0200
                Re: 0 vs. translate-none anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-09-23 17:25 +0000
                Re: 0 vs. translate-none peter <peter.noreply@tin.it> - 2025-09-23 22:25 +0200
                Re: 0 vs. translate-none albert@spenarnc.xs4all.nl - 2025-09-24 01:15 +0200
                Re: 0 vs. translate-none anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-09-24 06:26 +0000
            Re: 0 vs. translate-none albert@spenarnc.xs4all.nl - 2025-09-21 10:37 +0200
              Re: 0 vs. translate-none minforth <minforth@gmx.net> - 2025-09-21 13:56 +0200
                Re: 0 vs. translate-none albert@spenarnc.xs4all.nl - 2025-09-21 14:44 +0200
                Re: 0 vs. translate-none minforth <minforth@gmx.net> - 2025-09-21 17:46 +0200
                Re: 0 vs. translate-none anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-09-23 17:23 +0000
                Re: 0 vs. translate-none minforth <minforth@gmx.net> - 2025-09-23 22:38 +0200
                Re: 0 vs. translate-none anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-09-24 06:38 +0000
                Re: 0 vs. translate-none minforth <minforth@gmx.net> - 2025-09-24 09:39 +0200
                Re: 0 vs. translate-none albert@spenarnc.xs4all.nl - 2025-09-24 10:28 +0200
                Re: 0 vs. translate-none minforth <minforth@gmx.net> - 2025-09-24 10:44 +0200
                Re: 0 vs. translate-none minforth <minforth@gmx.net> - 2025-09-24 10:36 +0200
              Re: 0 vs. translate-none anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-09-21 12:50 +0000
                Re: 0 vs. translate-none albert@spenarnc.xs4all.nl - 2025-09-21 21:39 +0200
                Re: 0 vs. translate-none anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-09-22 06:56 +0000
                Re: 0 vs. translate-none albert@spenarnc.xs4all.nl - 2025-09-22 10:09 +0200
                Re: 0 vs. translate-none anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-09-22 08:39 +0000
                Re: 0 vs. translate-none albert@spenarnc.xs4all.nl - 2025-09-22 23:03 +0200
                Re: 0 vs. translate-none anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-09-23 17:00 +0000
                Re: 0 vs. translate-none albert@spenarnc.xs4all.nl - 2025-09-24 00:41 +0200
                Re: 0 vs. translate-none dxf <dxforth@gmail.com> - 2025-09-24 13:57 +1000
                Re: 0 vs. translate-none anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-09-24 06:45 +0000
                Re: 0 vs. translate-none dxf <dxforth@gmail.com> - 2025-09-25 15:22 +1000
                Re: 0 vs. translate-none anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-09-25 06:36 +0000
                Re: 0 vs. translate-none albert@spenarnc.xs4all.nl - 2025-09-25 13:00 +0200
                Re: 0 vs. translate-none anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-09-29 05:54 +0000
                Re: 0 vs. translate-none albert@spenarnc.xs4all.nl - 2025-09-29 11:03 +0200
                Re: 0 vs. translate-none anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2025-09-29 16:27 +0000
                Re: 0 vs. translate-none dxf <dxforth@gmail.com> - 2025-09-26 10:56 +1000
                Re: 0 vs. translate-none Hans Bezemer <the.beez.speaks@gmail.com> - 2025-09-26 17:09 +0200
                Re: 0 vs. translate-none dxf <dxforth@gmail.com> - 2025-09-29 00:42 +1000
                Re: 0 vs. translate-none Hans Bezemer <the.beez.speaks@gmail.com> - 2025-09-30 18:15 +0200
                Re: 0 vs. translate-none dxf <dxforth@gmail.com> - 2025-10-01 14:10 +1000
                Re: 0 vs. translate-none Hans Bezemer <the.beez.speaks@gmail.com> - 2025-10-02 15:48 +0200
  Re: 0 vs. translate-none Ruvim <ruvim.pinka@gmail.com> - 2025-09-26 02:19 +0400
    Re: 0 vs. translate-none Ruvim <ruvim.pinka@gmail.com> - 2025-09-27 13:43 +0400

csiph-web