• Re: VALUE and TO implementation

    From Anton Ertl@21:1/5 to Ruvim on Thu Aug 1 10:07:30 2024
    Ruvim <ruvim.pinka@gmail.com> writes:
    On 2024-07-31 21:33, Anton Ertl wrote:
    Maybe those who like this kind of
    TO implementation will make a proposal that means that you cannot
    POSTPONE TO with a user-defined POSTPONE.

    How?

    That's up to those to work out who would benefit from such a
    restriction. The alternative (which may require less work) is to
    implement TO in a way that makes such a restriction unnecessary (i.e.,
    such that POSTPONE TO works even with a user-defined and maybe also
    the system-defined POSTPONE).

    Disallow obtaining the name token for "to"? That's a very weak
    approach.

    That appears to be overly blunt to me and would be unlikely to gain my
    support.

    It seems, it is possible to test whether "to" is parsing, and if not, >redefine it to provide a parsing "to" in a standard system.

    I came up with the following test:

    0 value _v1 immediate
    0 value _v2

    : test(to)
    1 1
    [ 1 ] to _v1 _v2 [ ( 1 | 1 0 ) ?dup 2drop ]
    ( 1 | 1 0 ) ?dup 2drop
    ;
    test(to) _v2 [if]
    .( ["to" is not a parsing word] )
    [else]
    .( ["to" is a parsing word] )
    [then]

    This is clever. Given that your test uses only Forth-94 features,
    already Forth-94 can see the difference between parsing and
    non-parsing TO.

    Suddenly, compilation of "test(to)" failed in VfxForth, version
    VFX Forth 64 5.43 [build 0199] 2023-11-09 for Linux x64

    So, either this "test(to)" or VfxForth is not standard compliant.

    I see nothing here that makes TEST(TO) non-standard. One can condense
    the case where VFX fails into:

    0 value _v1 immediate
    : test-to 1 to _v1 ;

    VFX Forth 64 5.43 [build 0199] reacts with:

    Err# -4 ERR: Data stack underflow.
    : test-to 1 to _v1 ;
    ^

    Let's see how your test works for the original flag-setting TO
    (without optimizations):

    variable to-state false to-state !
    : to true to-state ! ;
    : value
    create ,
    does>
    to-state @ if
    ! false to-state !
    else
    @
    then ;

    Your test indeed outputs "["to" is not a parsing word]".

    - anton
    --
    M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
    comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
    New standard: https://forth-standard.org/
    EuroForth 2024: https://euro.theforth.net

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@21:1/5 to albert@spenarnc.xs4all.nl on Thu Aug 1 12:16:41 2024
    On Thu, 1 Aug 2024 12:01:06 +0000, albert@spenarnc.xs4all.nl wrote:
    If I redefine a CONSTANT SIZE , I rather use the standard
    1,000,000,000 'SIZE >DFA !
    instead of using a VALUE.

    Variable constants should be in everyone's toolbox. :o)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to minforth on Fri Aug 2 11:40:19 2024
    In article <1d5aac5e718a5ab8d983ec37aec32d81@www.novabbs.com>,
    minforth <minforth@gmx.net> wrote:
    On Thu, 1 Aug 2024 12:01:06 +0000, albert@spenarnc.xs4all.nl wrote:
    If I redefine a CONSTANT SIZE , I rather use the standard
    1,000,000,000 'SIZE >DFA !
    instead of using a VALUE.

    Variable constants should be in everyone's toolbox. :o)

    That must be of course "non-standard".
    Thanks.

    Groetjes Albert
    --
    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 -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@21:1/5 to All on Sat Aug 3 09:55:18 2024
    TO is not part of the CORE wordset, and the standard has no
    normative parts - only compliance requirements, which do not
    include TO. See standard section 5.

    So language lawyering seems rather insubstantial here.

    Don't nail your own foot to the floor...

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From mhx@21:1/5 to All on Sat Aug 3 10:49:48 2024
    FORTH> 0 value _v1 immediate ok
    FORTH> : test-to 1 to _v1 ; ok
    FORTH> see test-to
    Flags: TOKENIZE, ANSI
    : test-to 1 TO _v1 ; ok
    FORTH> : tt test-to _v1 . ; ok
    FORTH> see tt
    Flags: ANSI
    $01341640 : tt
    $0134164A mov $01341190 qword-offset, 1 d#
    $01341655 push $01341190 qword-offset
    $0134165B jmp .+10 ( $0124A102 ) offset NEAR
    FORTH> tt 1 ok
    FORTH>

    FWIW.

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to minforth on Sat Aug 3 14:19:34 2024
    minforth@gmx.net (minforth) writes:
    TO is not part of the CORE wordset, and the standard has no
    normative parts

    What makes you think so? Everything is normative that is not marked
    as informative (the appendices).

    - only compliance requirements, which do not
    include TO. See standard section 5.

    Sure, you can implement a Forth-94 or Forth-2012 system that
    implements only the core wordset. But if you implement TO and claim
    that your system is a standard system, your implementation of TO must
    behave as specified in the standard. See chapter 3:

    |No standard word provided by a system shall alter the system state in
    |a way that changes the effect of execution of any other standard word
    |except as provided in this standard.

    Don't nail your own foot to the floor...

    Of course, you are free to implement a non-standard system.

    - anton
    --
    M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
    comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
    New standard: https://forth-standard.org/
    EuroForth 2024: https://euro.theforth.net

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From minforth@21:1/5 to Ruvim on Sat Aug 3 19:50:28 2024
    On Sat, 3 Aug 2024 14:28:46 +0000, Ruvim wrote:
    Do not agree?

    I don't, because rejecting Stephen's (and other's) TO-implementation
    method just because of some old and unclear wording is against
    innovation and optimisation.

    From a higher perspective: Forth has not really innovated over the
    last 50 years. Forth-94 achieved streamlining Forth-79 and Forth-83.
    Since then: only minor fixes. IIRC Charles Moore did not like the
    standard because it fossilised history and stifled creativity.
    Factor and 8th went their own ways, incorporation modern programming
    language features.

    Of course, a standard is no place for innovation or new features.
    But dogmatic paper lawyering is like digging Forth's grave a little
    deeper.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Paul Rubin@21:1/5 to mhx on Sun Aug 4 01:05:03 2024
    mhx@iae.nl (mhx) writes:
    Am I the only one that thinks parsing words are an incredible nuisance?

    I haven't followed this whole thing and didn't realize a sane
    non-parsing TO was even possible. I've sometimes thought of a version
    of VALUE that makes two separate words, for reading and writing the
    value:

    17 XVALUE foo

    creates two words, "?foo" and "!foo". ?foo pushes the value from foo (initially 17) onto the stack. !foo moves TOS to foo.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From mhx@21:1/5 to All on Sun Aug 4 07:17:41 2024
    However, as I showed earlier, a parsing "TO" has several advantages over
    a non-parsing "TO".

    Am I the only one that thinks parsing words are an incredible nuisance?

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From mhx@21:1/5 to Paul Rubin on Sun Aug 4 09:38:00 2024
    On Sun, 4 Aug 2024 8:05:03 +0000, Paul Rubin wrote:

    [..] I've sometimes thought of a version
    of VALUE that makes two separate words, for reading and writing the
    value:

    17 XVALUE foo

    creates two words, "?foo" and "!foo". ?foo pushes the value from foo (initially 17) onto the stack. !foo moves TOS to foo.

    That would work too, but apart from messing up Forth's unspoken
    formatting guidelines, the scheme becomes impractical when you want to
    propel additional messages like +TO, -TO, 'OF (returns address of),
    0TO or CLEAR, SIZEOF and /OF . In practice, the latter two are used
    very infrequently.

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to mhx on Sun Aug 4 09:36:51 2024
    mhx@iae.nl (mhx) writes:
    Am I the only one that thinks parsing words are an incredible nuisance?

    No. They are one of the reasons for the STATE-smartness idiocy and
    they don't work with ]]...[[. In case of TO Gforth (development)
    implements a to-recognizer:

    5 value foo
    7 ->foo
    foo . \ 7
    : bar ->foo ;
    9 bar
    foo . \ 9
    : bla ]] ->foo [[ ; immediate
    : blub bla ;
    3 blub
    foo . \ 3

    The to-recognizer makes TO unnecessary (both parsing or non-parsing).
    And instead of +TO FOO one writes +>FOO:

    6 +>foo
    foo . 9

    - anton
    --
    M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
    comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
    New standard: https://forth-standard.org/
    EuroForth 2024: https://euro.theforth.net

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to mhx on Sun Aug 4 13:11:03 2024
    In article <23a44aa0445a30c0fc782819f48463f9@www.novabbs.com>,
    mhx <mhx@iae.nl> wrote:
    However, as I showed earlier, a parsing "TO" has several advantages over
    a non-parsing "TO".

    Am I the only one that thinks parsing words are an incredible nuisance?

    Numbers (denotations) must be parsed. Otherwise I do think parsing
    words is a nuisance.
    I might tolerate an exception with
    "FILENAME" INCLUDED
    "FILESNAME" NEEDED
    "WORDNAME" WANTED
    to be supplemented with
    INCLUDE FILENAME
    NEED FILESNAME
    WANT WORDNAME
    Merely for convenience to not type double quotes that are
    far from the hand position, and even have different position
    on the keyboard. And only in interactive sessions.

    Particularly I hate ' / ['] .
    My solution that ' has to elevated to a denotation.
    Meaning 'someword leave the address/dea/handle/nametoken
    of `` someword '' that is the same in interpret and compile mode.
    If you want separate behaviours in some mode, they must be arrived
    at via the dea.


    -marcel

    Groetjes Albert
    --
    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 -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Stephen Pelc@21:1/5 to All on Mon Aug 5 09:28:14 2024
    On 4 Aug 2024 at 08:17:41 BST, "mhx" <mhx> wrote:

    However, as I showed earlier, a parsing "TO" has several advantages over
    a non-parsing "TO".

    Am I the only one that thinks parsing words are an incredible nuisance?

    No.

    Stephen
    --
    Stephen Pelc, stephen@vfxforth.com
    MicroProcessor Engineering, Ltd. - More Real, Less Time
    133 Hill Lane, Southampton SO15 5AF, England
    tel: +44 (0)78 0390 3612, +34 649 662 974
    http://www.mpeforth.com
    MPE website
    http://www.vfxforth.com/downloads/VfxCommunity/
    downloads

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From mhx@21:1/5 to dxf on Mon Aug 5 12:38:09 2024
    On Mon, 5 Aug 2024 12:26:26 +0000, dxf wrote:

    On 4/08/2024 5:17 pm, mhx wrote:
    However, as I showed earlier, a parsing "TO" has several advantages over >>> a non-parsing "TO".

    Am I the only one that thinks parsing words are an incredible nuisance?

    Don't know but to this day Mitch Bradley (ANS, Open Firmware) still uses parsing words to interpret hex, double, float numbers.

    "de gustibus non disputandum est."

    He also uses state-smart words.

    Show me a Forther *without* strong opinions *and* unfathomable
    inconsistencies.

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to mhx on Mon Aug 5 15:18:00 2024
    mhx@iae.nl (mhx) writes:
    On Mon, 5 Aug 2024 12:26:26 +0000, dxf wrote:
    Don't know but to this day Mitch Bradley (ANS, Open Firmware) still uses
    parsing words to interpret hex, double, float numbers.

    "de gustibus non disputandum est."

    He also uses state-smart words.

    Show me a Forther *without* strong opinions *and* unfathomable >inconsistencies.

    In this case it's actually consistent: Mitch Bradley finds the
    pitfalls of STATE-smart words acceptable, so he uses such words to
    deal with various literals.

    I, OTOH, don't consider them to be acceptable, so I prefer
    recognizers, like the standard already has for words, single and
    double integer numbers, and FP numbers.

    - anton
    --
    M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
    comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
    New standard: https://forth-standard.org/
    EuroForth 2024: https://euro.theforth.net

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to Anton Ertl on Tue Aug 6 10:58:54 2024
    In article <2024Aug5.171800@mips.complang.tuwien.ac.at>,
    Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
    mhx@iae.nl (mhx) writes:
    On Mon, 5 Aug 2024 12:26:26 +0000, dxf wrote:
    Don't know but to this day Mitch Bradley (ANS, Open Firmware) still uses >>> parsing words to interpret hex, double, float numbers.

    "de gustibus non disputandum est."

    He also uses state-smart words.

    Show me a Forther *without* strong opinions *and* unfathomable >>inconsistencies.

    In this case it's actually consistent: Mitch Bradley finds the
    pitfalls of STATE-smart words acceptable, so he uses such words to
    deal with various literals.

    I, OTOH, don't consider them to be acceptable, so I prefer
    recognizers, like the standard already has for words, single and
    double integer numbers, and FP numbers.

    Actually there is not much difference between
    DX ABCD
    and
    0x ABCD
    and
    0xABCD
    or
    $ABCD

    As long as you make 0x/$ a PREFIX and recognize that
    it is inevitable that numbers are state-smart.
    Making the expression into a single word solves much.
    The whole recognizer thing becomes superfluous at the expense
    of 5 words in INTERPRET.

    - anton

    Groetjes Albert
    --
    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 -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to dxf on Wed Aug 7 06:11:03 2024
    dxf <dxforth@gmail.com> writes:
    On 6/08/2024 2:27 pm, dxf wrote:
    ...
    ISTR dual-xt solutions also have problems with 'edge cases'.

    Works for state-smart but not dual-xt:

    : ," postpone s" dup c, here over allot swap cmove ;

    ," Hello world"

    I did not understand at first what this code was supposed to do, in
    particular why you would want to perform the compilation semantics of
    S" outside a colon definition.

    After some thinking I found that this code actually relies on a buggy implementation of S" which does not implement the compilation
    semantics of the standard S" in this usage. It's better to write code
    that does not rely on such bugs:

    : ," ['] s" execute dup c, here over allot swap cmove ;

    ," Hello world"

    or just

    : ," '"' parse dup c, here over allot swap cmove ;

    ," Hello world"

    As for the argument that this is supposed to be a problem of correct implementations of S": Yes, one can write code that relies on a bug,
    for every bug. That does not justify the bug.

    - anton
    --
    M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
    comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
    New standard: https://forth-standard.org/
    EuroForth 2024: https://euro.theforth.net

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to dxforth@gmail.com on Wed Aug 7 12:09:04 2024
    In article <66b2e541$1@news.ausics.net>, dxf <dxforth@gmail.com> wrote:
    On 6/08/2024 2:27 pm, dxf wrote:
    ...
    ISTR dual-xt solutions also have problems with 'edge cases'.

    Works for state-smart but not dual-xt:

    : ," postpone s" dup c, here over allot swap cmove ;

    ," Hello world"

    Perhaps it's time to consider all 'smart' words 'evil'.


    Numbers (also denotations, such as strings) must be smart.
    There is no harm because they are constant.
    As far as I'm concerned all others can be banned.
    Most state-smart words in my Forth are relics from old standards.
    I routinely replace
    ."
    by
    "..." TYPE

    Groetjes Albert
    --
    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 -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Paul Rubin@21:1/5 to albert@spenarnc.xs4all.nl on Wed Aug 7 12:35:28 2024
    albert@spenarnc.xs4all.nl writes:
    Numbers (also denotations, such as strings) must be smart.

    I've thought of having non-smart numbers in a small Forth. Instead of
    123 you would say # 123 or something similar, where # is a parsing word
    that emits LIT and the number. I remember that the eForth metacompiler
    does something like that, to handle the case where the host and target processors have differing number representations (e.g. word sizes).

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to no.email@nospam.invalid on Thu Aug 8 11:25:51 2024
    In article <87le18rurj.fsf@nightsong.com>,
    Paul Rubin <no.email@nospam.invalid> wrote:
    albert@spenarnc.xs4all.nl writes:
    Numbers (also denotations, such as strings) must be smart.

    I've thought of having non-smart numbers in a small Forth. Instead of
    123 you would say # 123 or something similar, where # is a parsing word
    that emits LIT and the number. I remember that the eForth metacompiler
    does something like that, to handle the case where the host and target >processors have differing number representations (e.g. word sizes).

    I don't think that would count as non-smart numbers.
    A long time ago I demonstrated handling denotations (numbers)
    in INTERPRET . Reminder denotations are constant and the same
    in either mode.
    It requires that there is a separate compilation stack.

    As soon as INTERPRET detects that a word (obviously immediate)
    leaves something on the stack, and it is in compilation state,
    it compiles one or more literals.
    That is in the context of PREFIXes. 0x is a prefix immediate.
    0x1234 gets control and generates hex 1234 . INTERPRET takes
    cares of the rest.
    Bottom line, that is the single location in the whole Forth
    where STATE is inspected.

    In ciforth I don't go that far, but all denotations ends in a
    call to LITERAL/DLITERAL which comes close.

    Groetjes Albert


    --
    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 -

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)