• Re: THROW codes and ambiguous conditions

    From Anton Ertl@21:1/5 to dxf on Sat May 31 06:02:48 2025
    dxf <dxforth@gmail.com> writes:
    AFAICS the statement in Section 9.3.5

    "A system choosing to execute THROW when detecting one of the ambiguous
    conditions listed in table 9.2 shall use the throw code listed there."

    effectively rules out the traditional use of ABORT" to convey the ambiguous >conditions listed in the table. Is that how others read it?

    Given that the standard states elsewhere that there is no guarantee of
    any system behaviour at all in case of an ambiguous condition, this
    statement and its use of "shall" is strange.

    Let's see what the existing practice is. I try the following on
    various Forth systems:

    s" include xxxxxxxx.fs" ' evaluate catch .
    s" include /tmp/x.fs" ' evaluate catch .

    where xxxxxxxx.fs does not exist, and /tmp/x.fs exists but the
    permissions are such that you cannot open it for reading.

    What I get on various Forth systems running on Linux is:

    xxxxxxxx.fs /tmp/x.fs
    -514 -525 Gforth
    -37 -37 iforth 5.1-mini
    -261 -261 lxf 1.7-172-983
    -199 -199 SwiftForth i386-Linux 3.11.0
    -69 -69 SwiftForth x64-Linux 4.0.0-RC89
    -258 -258 VFX Forth 64 5.43

    So out of these five systems, only two use values from the table, and
    these two use different throw codes. Only one uses a throw code from
    the original 50 that Mitch Bradley had in mind when creating the
    table.

    Looking at 11.6.1.1718 INCLUDED, it says:

    |An ambiguous condition exists if the named file can not be opened, if
    |an I/O exception occurs reading the file, or if an I/O exception
    |occurs while closing the file.

    Table 9.1 of Forth-2012 lists:

    -37 file I/O exception
    -38 non-existent file
    -69 OPEN-FILE

    Looking at 11.4.1.2 of Forth-94 <https://www.complang.tuwien.ac.at/forth/dpans-html/dpans11.htm>, it
    lists the following ambiguous conditions for INCLUDED:

    * I/O exception reading or closing fileid (11.6.1.1717 INCLUDE-FILE,
    11.6.1.1718 INCLUDED);
    * named file cannot be opened (11.6.1.1718 INCLUDED);

    It's unclear how these ambiguous conditions should be mapped to the
    throw codes.

    In any case, -38 is the best match for the xxxxxxxx.fs case, and among
    the first 50, -37 is the best match for the /tmp/x.fs case; with the
    addition of -69 in Forth-2012, -69 is also a contender; however, the
    throw codes -59..-76 were intended for explicit throws of iors, not
    for ambiguous conditions (neither the proponent of that addition nor
    the committee ever discussed the chapter where the table is defined).

    Since it's inception, Gforth has thrown other throw codes in all cases
    where the OS reported a failure (as is the case here: -514 means "No
    such file or directory" and -525 means "Permission denied") and in
    some cases when the OS raised a signal, and nobody has complained
    about that yet; the fact that several other Forth systems do not use
    throw codes from Table 9.1 for these ambiguous conditions indicates
    that their authors have not received complaints about that, either.

    But maybe Forth, Inc. received such a complaint, and that's why they
    changed the throw code from -199 to -69. Or maybe not: The fact that
    they changed the throw code indicates that they do not worry that
    their customers have programs written for their old throw codes; note
    also that if the system catches a -199 THROW on SwiftForth 3.11, it
    reports "Can't open file", just like SwiftForth 4.0.0-RC89 does when
    it catches a -69 THROW. Doing the other throw on either version
    produces the following messages: "Catch = -69" and "Catch = -199".

    My guess is that those programmers who catch such ambiguous conditions
    do not check the actual throw codes, at least not if they write
    programs intended to be portable across systems (some may be writing system-specific programs and check for the specific throw codes these
    systems produce; but the renumbering in SwiftForth indicates that
    Forth, Inc. does not expect that their users do that even in a
    system-specific way).

    So I would not worry about that.

    Early on DX-Forth it became apparent that maintaining a list of error >messages accessible by means of a THROW code was going to be messy and
    worse - costly. I wanted CATCH THROW but could do without the vision
    ANS appeared to have in mind for it. The consequence of retaining
    ABORT" for classic ambiguous conditions means I can't individually
    identify them at CATCH but I've yet to find this a problem.

    It probably is not a problem, but your claim of a high cost seems
    curious. It seems to me that

    open-file throw

    is cheaper than

    open-file abort" OPEN-FILE failed in INCLUDED"

    and that reporting something like "Catch = -37" or somesuch is not
    costly to implement at all. And if you want more descriptive error
    messages in a resource-constrained and otherwise traditional setting,
    using the throw code to select a line from a sequence of blocks does
    not seem to be particularly expensive, either.

    I'm curious whether others found ANS' requirement above 'a step too far'?

    It seems that if we have noticed it at all, many of us chose to ignore
    it.

    However, in the case of signals Gforth goes to quite some lengths to
    actually translate it to the right Forth exception, and while we are
    at it, also produce a throw code from table 9.1.

    E.g., when it receives a SIGFPE, it looks at the si_code of the
    signal, and if that is FPE_INTDIV (integer division error), the
    debugging engine (gforth) checks if the divisor is 0. If so, it
    throws -10 (division by zero), otherwise (e.g., on $8000000000000000
    -1 / ) it throws -11 (Result out of range).

    Another example is SIGSEGV. It looks up the accessed memory address
    (si_addr), and depending on where that points to, throws one of:

    -3 Stack overflow
    -4 Stack underflow
    -5 Return stack overflow
    -6 Return stack underflow
    -8 Dictionary overflow
    -9 Invalid memory address
    -44 Floating-point stack overflow
    -45 Floating-point stack underflow
    -2058 locals stack overflow
    -2059 locals stack underflow

    I don't think that the resulting throw codes are checked in any
    programs, but I expect that the users find the error messages (when
    the system catches the exception) helpful; I certainly do.

    - 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 2023 proceedings: http://www.euroforth.org/ef23/papers/
    EuroForth 2024 proceedings: http://www.euroforth.org/ef24/papers/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to Anton Ertl on Sat May 31 13:53:58 2025
    In article <2025May31.080248@mips.complang.tuwien.ac.at>,
    Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
    dxf <dxforth@gmail.com> writes:
    AFAICS the statement in Section 9.3.5

    "A system choosing to execute THROW when detecting one of the ambiguous
    conditions listed in table 9.2 shall use the throw code listed there."

    effectively rules out the traditional use of ABORT" to convey the ambiguous >>conditions listed in the table. Is that how others read it?

    Given that the standard states elsewhere that there is no guarantee of
    any system behaviour at all in case of an ambiguous condition, this
    statement and its use of "shall" is strange.

    Let's see what the existing practice is. I try the following on
    various Forth systems:

    s" include xxxxxxxx.fs" ' evaluate catch .
    s" include /tmp/x.fs" ' evaluate catch .

    where xxxxxxxx.fs does not exist, and /tmp/x.fs exists but the
    permissions are such that you cannot open it for reading.

    What I get on various Forth systems running on Linux is:

    xxxxxxxx.fs /tmp/x.fs
    -514 -525 Gforth
    -37 -37 iforth 5.1-mini
    -261 -261 lxf 1.7-172-983
    -199 -199 SwiftForth i386-Linux 3.11.0
    -69 -69 SwiftForth x64-Linux 4.0.0-RC89
    -258 -258 VFX Forth 64 5.43

    -2 -13 ciforth on (whatever) linux

    -13 MESSAGE
    : Permission denied
    OK
    -2 MESSAGE
    : No such file or directory
    OK

    Am I the only to use the Unix error codes?

    You could also try:

    INCLUDE x.fs
    ? ciforth ERROR # -13 : Permission denied


    So out of these five systems, only two use values from the table, and
    these two use different throw codes. Only one uses a throw code from
    the original 50 that Mitch Bradley had in mind when creating the
    table.

    <SNIP>


    It's unclear how these ambiguous conditions should be mapped to the
    throw codes.

    I think it is dubious how mapping errors on predefined error codes
    is helpful. Supposedly to make programs portable from unix to windows?
    (HA HA).
    If you get an error code from linux, there is no way you can improve
    that through altering or mapping it.


    In any case, -38 is the best match for the xxxxxxxx.fs case, and among
    the first 50, -37 is the best match for the /tmp/x.fs case; with the
    addition of -69 in Forth-2012, -69 is also a contender; however, the
    throw codes -59..-76 were intended for explicit throws of iors, not
    for ambiguous conditions (neither the proponent of that addition nor
    the committee ever discussed the chapter where the table is defined).

    This is an example of time wasted to second guess what error code are
    supposed to mean.


    It probably is not a problem, but your claim of a high cost seems
    curious. It seems to me that

    open-file throw

    is cheaper than

    open-file abort" OPEN-FILE failed in INCLUDED"

    Also throw codes are superior.

    "tetris.cfg" R/O OPEN-FILE
    DUP -2 = IF DROP 0 ( a missing configuration is not an error) THEN
    THROW

    I don't think that the resulting throw codes are checked in any
    programs, but I expect that the users find the error messages (when
    the system catches the exception) helpful; I certainly do.

    This is where QUIT comes in. You can couple to
    a library where all codes are explained. If you do, QUIT presents
    the message. If you are not, my ciforth's outputs the error code
    in decimal on the error channel. This is hard evidence.
    Either it is an OS system code, or it is a number that you can google
    (grep) in the source files. And no, it makes no sense to use
    "self-documenting names" for one-time-use errors.
    I detest the skimpy messages ABORT" allows us. Soooo 16-bit era.
    In programs I write error codes are never used for difference purposes,
    and I document it extensively.

    Consider this (from my transputer prime counting program. MCMXCIX)

    15 In learn too many mask in the uncompressed table are trivial.
    (more thant BITS_PER_ENTRY).
    This is a program error, e.g. caused by trying to learn a
    number that is too composite, such as divisable by a prime
    less or equal 7.

    16 A candidate prime number should use all of the masks of the
    array lmask (based on mathematical considerations).
    The module `learn' discovers that it doesnot use all of the
    masks, or more than the expected number (in combination with
    ERROR 15).

    Exercise: come up with an ABORT" message or a "self documenting
    name" for above errors.

    - anton

    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to albert@spenarnc.xs4all.nl on Sat May 31 16:07:36 2025
    albert@spenarnc.xs4all.nl writes:
    In article <2025May31.080248@mips.complang.tuwien.ac.at>,
    Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
    xxxxxxxx.fs /tmp/x.fs
    -514 -525 Gforth
    -37 -37 iforth 5.1-mini
    -261 -261 lxf 1.7-172-983
    -199 -199 SwiftForth i386-Linux 3.11.0
    -69 -69 SwiftForth x64-Linux 4.0.0-RC89
    -258 -258 VFX Forth 64 5.43

    -2 -13 ciforth on (whatever) linux

    -13 MESSAGE
    : Permission denied
    OK
    -2 MESSAGE
    : No such file or directory
    OK

    Am I the only to use the Unix error codes?

    You seem to be the only one who remaps them by just negating them.
    This remaps them right into the range of throw codes that are
    preassigned by the Forth standard in table 9.1.

    If you look at the results above, you will find that Gforth remaps
    errno into the ior -512-errno (e.g., -514 for "No such file or
    directory, and -525 for "permission denied"), and INCLUDED THROWs that
    ior.

    For Unix signals, if Gforth does not translate them to one of the
    predefined throw codes or handles the signal in some other way (e.g.,
    SIGWINCH just changes what FORM returns, and is otherwise
    transparent), it throws -256-sig.

    - 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 2023 proceedings: http://www.euroforth.org/ef23/papers/
    EuroForth 2024 proceedings: http://www.euroforth.org/ef24/papers/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to Anton Ertl on Sun Jun 1 12:47:42 2025
    In article <2025May31.180736@mips.complang.tuwien.ac.at>,
    Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
    albert@spenarnc.xs4all.nl writes:
    In article <2025May31.080248@mips.complang.tuwien.ac.at>,
    Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
    xxxxxxxx.fs /tmp/x.fs
    -514 -525 Gforth
    -37 -37 iforth 5.1-mini
    -261 -261 lxf 1.7-172-983
    -199 -199 SwiftForth i386-Linux 3.11.0
    -69 -69 SwiftForth x64-Linux 4.0.0-RC89
    -258 -258 VFX Forth 64 5.43

    -2 -13 ciforth on (whatever) linux

    -13 MESSAGE
    : Permission denied
    OK
    -2 MESSAGE
    : No such file or directory
    OK

    Am I the only to use the Unix error codes?

    You seem to be the only one who remaps them by just negating them.
    This remaps them right into the range of throw codes that are
    preassigned by the Forth standard in table 9.1.


    Actually, the error returns from system calls are negative
    numbers. So I do approximately:
    ( open file ) DUP 0 MIN THROW \ Now the result is a file channel id.
    So I was puzzled at the term remapping. Indeed the man 3 errno
    reveals that positive numbers are intended.

    If you look at the results above, you will find that Gforth remaps
    errno into the ior -512-errno (e.g., -514 for "No such file or
    directory, and -525 for "permission denied"), and INCLUDED THROWs that
    ior.

    I could add -512 to them. ciforth has as one of its names
    "close to ISO" Forth. This discussion proves that adhering to
    the exact throw cause is of dubious value.
    One of my design goals was simplicity and usability at the expense of
    speed and traditional expectations. This was one of the corners cut
    off. The positive errors are not compliant anyway.
    E.g. gforth error number 13 (not-found compliant) is split into error 10 (malformed number) and 12 (not found in the search order).


    For Unix signals, if Gforth does not translate them to one of the
    predefined throw codes or handles the signal in some other way (e.g., >SIGWINCH just changes what FORM returns, and is otherwise
    transparent), it throws -256-sig.

    gforth is a politically correct implementation. That is much
    appreciated. It takes a team to maintain that and study the
    standard extensively. That niche has been filled, so if that
    was my priority I'd join the gforth team.

    ciforth has no gratituous deviations from the standard
    (by my arbitration), but it violates traditional expectations.


    - anton

    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to albert@spenarnc.xs4all.nl on Sun Jun 1 15:15:42 2025
    albert@spenarnc.xs4all.nl writes:
    Actually, the error returns from system calls are negative
    numbers. So I do approximately:
    ( open file ) DUP 0 MIN THROW \ Now the result is a file channel id.
    So I was puzzled at the term remapping. Indeed the man 3 errno
    reveals that positive numbers are intended.

    It depends on the architecture how an error from a system call is
    indicated; on some architectures the result is only returned in one
    register, on some it's a register and a flag (IIRC the carry flag).

    In the latter case a set flag indicates that the register contains an
    error code, while a clear flag indicates that there was no error and
    the register contains the result.

    If there is only one register, you have to find out it the result is a
    success or an error. Many system calls are designed to produce a
    positive result (e.g., write() or read()), and using the negative
    number range for error results is the solution for that; that's why
    you are seeing the negated errno.

    It becomes tricky to do system calls like sbrk() and mmap() that
    return addresses, because in principle any bit pattern can be an
    address. But originally Unix and Linux reserved the high half of
    address space for the system, so these system calls, which return
    user-level addresses, could only return addresses where the MSB is
    clear. Towards the end of the 32-bit era, user space could reach up
    to 3GB, so just checking the sign was not enough, but there was still
    1G of numbers that could be used as error returns.

    This discussion proves that adhering to
    the exact throw cause is of dubious value.

    There is apparently little usage of catching specific throw codes.
    E.g., I have never done that.

    However, throwing specific codes is a different issue. I have done
    so, and I have discussed with other people which existing throw codes
    are appropriate for which error. An example is shown in <2024Apr1.115659@mips.complang.tuwien.ac.at>:

    : gen-mask3 ( n -- x )
    \ throw if <n>=0
    64 swap - dup 64 u< 0= -24 and throw -1 swap lshift ;

    Will 0 GEN-MASK3 give the error message "Too many open files" or
    "Invalid numeric argument" on ciforth?

    - 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 2023 proceedings: http://www.euroforth.org/ef23/papers/
    EuroForth 2024 proceedings: http://www.euroforth.org/ef24/papers/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to Anton Ertl on Sun Jun 1 19:35:37 2025
    In article <2025Jun1.171542@mips.complang.tuwien.ac.at>,
    Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
    albert@spenarnc.xs4all.nl writes:
    Actually, the error returns from system calls are negative
    numbers. So I do approximately:
    ( open file ) DUP 0 MIN THROW \ Now the result is a file channel id. >>So I was puzzled at the term remapping. Indeed the man 3 errno
    reveals that positive numbers are intended.

    It depends on the architecture how an error from a system call is
    indicated; on some architectures the result is only returned in one
    register, on some it's a register and a flag (IIRC the carry flag).

    I have experience in Intel. (ciforth=common intel Forth).
    In a surprising large number of Intel : 32/64 MS linux openbsd intel-osx
    the result is returned in AX.
    On ARM linux R0 is used.
    On riscv linux a0 is used.
    The unix like community is consistent in this.
    Unfortunately Microsoft tells to find the meaning in the hard to find documentation, so it is call dependant. But for a large class of ddl
    calls this convention is upheld, at least for the SYSTEM32.SYS stuff.
    "DUP 0 MIN" often finds an error code, but I must combine it with the
    result of GetLastError@0 sometimes.
    Note that dll's are not only "system calls", Anybody can write a dll
    library and make a dogs dinner out of it and forget to document.
    In this respect dll's are more like .so files.


    In the latter case a set flag indicates that the register contains an
    error code, while a clear flag indicates that there was no error and
    the register contains the result.

    If there is only one register, you have to find out it the result is a >success or an error. Many system calls are designed to produce a
    positive result (e.g., write() or read()), and using the negative
    number range for error results is the solution for that; that's why
    you are seeing the negated errno.

    It becomes tricky to do system calls like sbrk() and mmap() that
    return addresses, because in principle any bit pattern can be an
    address. But originally Unix and Linux reserved the high half of
    address space for the system, so these system calls, which return
    user-level addresses, could only return addresses where the MSB is
    clear. Towards the end of the 32-bit era, user space could reach up
    to 3GB, so just checking the sign was not enough, but there was still
    1G of numbers that could be used as error returns.

    So far so good. This system holds surprisingly well.


    This discussion proves that adhering to
    the exact throw cause is of dubious value.

    There is apparently little usage of catching specific throw codes.
    E.g., I have never done that.

    However, throwing specific codes is a different issue. I have done
    so, and I have discussed with other people which existing throw codes
    are appropriate for which error. An example is shown in ><2024Apr1.115659@mips.complang.tuwien.ac.at>:

    : gen-mask3 ( n -- x )
    \ throw if <n>=0
    64 swap - dup 64 u< 0= -24 and throw -1 swap lshift ;

    Will 0 GEN-MASK3 give the error message "Too many open files" or
    "Invalid numeric argument" on ciforth?

    0 gen-mask3 ? ciforth ERROR # -24 : Too many open files

    (Not OK).


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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to the.beez.speaks@gmail.com on Mon Jun 2 12:44:03 2025
    In article <nnd$5d07338c$61b87fbd@d4d89ef8da41e19e>,
    Hans Bezemer <the.beez.speaks@gmail.com> wrote:
    On 31-05-2025 03:10, dxf wrote:
    <SNIP>
    not a "hard" code. I mean, even in their freshman years CS students are >taught to use enums and constants instead of literals.

    That is constants that are used more than once with the same meaning.
    It is a deadly sin to use throw codes more than once, so this doesn't
    apply.

    Hans Bezemer
    --
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From mhx@21:1/5 to dxf on Tue Jun 3 06:04:27 2025
    On Tue, 3 Jun 2025 3:23:03 +0000, dxf wrote:
    [..]
    In the early days of microcomputing memory was severely limited and
    error codes were used to save space. But how much need today and
    what's wrong with ABORT"?
    I don't use forth for scripting which might require sending codes and
    can't think of an app where I've used codes. Is the ANS list of
    error codes aimed at special needs? Because FWIW I'm not feeling any.

    Maybe (targetting [embedded] apps for) users that don't speak English?

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to dxf on Tue Jun 3 06:10:34 2025
    dxf <dxforth@gmail.com> writes:
    In the early days of microcomputing memory was severely limited and error codes
    were used to save space.

    And for many in the Forth community these times are not over. They
    argue with embedded systems, with retro systems such as an 8086 Forth,
    with Chuck Moore quotes or with 10x 100x 1000x ... efficiency (ok,
    that was Jeff Fox's specialty), and denounce everything that they
    dislike as consuming too much memory.

    Of course, when there is something they like and that consumes memory,
    or something that they dislike and that reduces memory consumption,
    they do not apply any of these considerations.

    But how much need today and what's wrong with ABORT"?

    My guess at the thinking behind the Forth-94 committee's decisions
    about that are:

    1) ABORT" Undefined word" takes more space than -13 AND THROW. Of
    course, if the system then has a table for translating throw codes
    to messages, that probably eliminates the memory savings, but a
    system that is really tight on memory can just output the error
    code and leave it to the user to look the error up in the manual.

    2) For CATCH, every ABORT" looks the same, so you cannot do something
    for one kind of error and something else for other kinds. Of
    course, the question is whether one can do that with the current
    situation (apparently not portably for inaccessible or non-existent
    files in INCLUDED), and whether that's something that Forth
    programmers would make use of if the situation was otherwise.

    One interesting aspect is that IIRC Mitch Bradley uses

    C" <error message>" throw

    or somesuch. If you want to catch that, you have to do it as
    follows:

    : printer-on-fire c" printer on fire" ;

    : foo ... catch dup printer-on-fire = if ... then ... ;
    : bar ... printer-on-fire throw ... ;

    And of course, this only make sense if the system treats an
    uncaught throw as a counted string to be printed.

    I don't use forth for scripting which might require sending codes and can't think
    of an app where I've used codes.

    Actually, there's a pitfall there:

    In Unix, the exit code is an 8-bit unsigned value, and 0 means
    success. At one point, deelopment Gforth in scripting mode just used
    the throw code as exit code; its low 8 bits became the actual exit
    code, so "256 throw" appeared to be a success. Currently, throw codes
    1..255 are used as exit codes, and all other uncaught non-zero THROWs
    in scripting mode result in exit code 1.

    - 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 2023 proceedings: http://www.euroforth.org/ef23/papers/
    EuroForth 2024 proceedings: http://www.euroforth.org/ef24/papers/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From John@21:1/5 to dxf on Tue Jun 3 03:43:29 2025
    On 6/2/25 10:23 PM, dxf wrote:
    On 3/06/2025 5:20 am, Hans Bezemer wrote:
    On 02-06-2025 12:44, albert@spenarnc.xs4all.nl wrote:
    In article <nnd$5d07338c$61b87fbd@d4d89ef8da41e19e>,
    Hans Bezemer  <the.beez.speaks@gmail.com> wrote:
    On 31-05-2025 03:10, dxf wrote:
    <SNIP>
    not a "hard" code. I mean, even in their freshman years CS students are >>>> taught to use enums and constants instead of literals.

    That is constants that are used more than once with the same meaning.
    It is a deadly sin to use throw codes more than once, so this doesn't
    apply.

    Hans Bezemer

    Wrong. It's a way to abstract a numerical literal - so if things happen to change, you don't have to change them everywhere. It's also a way to self-document a program. Any idea what -22 THROW does (without consulting the standard)? Any idea what E.
    BADADR THROW does?

    In the early days of microcomputing memory was severely limited and error codes
    were used to save space. But how much need today and what's wrong with ABORT"?
    I don't use forth for scripting which might require sending codes and can't think
    of an app where I've used codes. Is the ANS list of error codes aimed at special
    needs? Because FWIW I'm not feeling any.



    Oh dear... brings up an amusing and, at the time, a tedious customer interaction...

    I was leading a group of non-native English speaking programmers making
    Windows applications. And of course they tried to save space in the
    error string table. One of the windows in the system was the 'Analysis Window'.

    When the error came it proclaimed a fault in the user's Anal Wind.

    Customer support loved that one. My boss didn't.

    -J

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to the.beez.speaks@gmail.com on Tue Jun 3 12:30:00 2025
    In article <nnd$4a556964$65be8f1e@0fce8f78c54657e5>,
    Hans Bezemer <the.beez.speaks@gmail.com> wrote:
    On 02-06-2025 12:44, albert@spenarnc.xs4all.nl wrote:
    In article <nnd$5d07338c$61b87fbd@d4d89ef8da41e19e>,
    Hans Bezemer <the.beez.speaks@gmail.com> wrote:
    On 31-05-2025 03:10, dxf wrote:
    <SNIP>
    not a "hard" code. I mean, even in their freshman years CS students are
    taught to use enums and constants instead of literals.

    That is constants that are used more than once with the same meaning.
    It is a deadly sin to use throw codes more than once, so this doesn't
    apply.

    Hans Bezemer

    Wrong. It's a way to abstract a numerical literal - so if things happen
    to change, you don't have to change them everywhere. It's also a way to >self-document a program. Any idea what -22 THROW does (without
    consulting the standard)? Any idea what E.BADADR THROW does?


    It is a deadly sin to change error numbers. Or reuse them if they
    are no longer used.

    I do get a hint, because QUIT looks up -22, if possible.

    The c-people hide from you the actual number E.BADADR.
    If they throw it, you are left with

    ? ciforth ERROR # -1001 : (No text message available for this error)



    Yesterday, while consulting the ANS error table, I found that with a
    little imagination, I could standardize three more errors. Since there
    is a table for the codes and one for the error messages, one set in
    Forth and one set in C - I had to change four files. Since I'm quite a >disciplined programmer, always using the symbols, that's all I had to
    change.

    Standardize errors is a waste of time. Instead document errors.


    Hans Bezemer
    --
    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From sjack@21:1/5 to dxf on Tue Jun 3 20:48:40 2025
    dxf <dxforth@gmail.com> wrote:

    MS-DOS errors are mapped to 'ior' using $FExx (CHForth trick)


    At one time I had catch/throw integrated with FigForth ERROR (was
    workable but hard to explain). Any system error (negative IOR)
    would throw a system ERROR code and would provide the IOR as data.
    Catch caught the ERROR code (positive number) and could key off the
    IOR code for any action it would want to take. Of course this doesn't
    address portability issue as to standard code and standard response.

    Also had file of Linux error code descriptions to view with external
    resource, no impact on Forth. Seldom made use of it. For savvy users
    an error code alone suffice as to error cause e.g. 'fail to open a
    non-existing file, most likely a typo in the file path'. I don't
    discount an astronaut landing on the moon being highly concerned by
    streaming printouts of 1202 and 1201 codes. Streaming text wouldn't
    had been any better because the astronauts hadn't been 'trained' for
    that situation. (Somewhat similar, drilling rig tips over in North Sea
    because tool-pusher couldn't comprehend the manual instructions in
    time to fix stabilizers). Instructions provide the illusion of
    being taken care of and is often championed by marketing, activists and
    other puffer fish wanting to maintain a middle man position. I admit not
    all is so nefarious though I smile sometimes to see who is pushing what.

    Me, I'm 'Tool-Time' by nature. Give me a bigger hammer and I'll fix
    it, or break it. X-wife on the other hand, a very intelligent retired
    teacher, is big on instructions. She hopeless in operating a smart
    phone. If instructions fail to give wanted results, mouth is quick to
    engage. Not a moment is given to 'thinking' what could possibly have
    gone wrong. Wouldn't do any good anyways; she has very little to work
    with. Now despite what some shallow-minded feminist will happily
    construe, I'm not being mean. It's a fact thinking requires some
    basic concepts to work with. If such were not accrued for whatever
    reason, then whining is the only recourse for the moment.
    Unfortunately, the epiphany never occurs that now would be a good time
    to start rectifying that problem.

    --
    me
    'The Sleep of Reason Produces Monsters' -- Goya

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From sean@conman.org@21:1/5 to It was thus on Wed Jun 4 19:25:08 2025
    It was thus said that the Great dxf <dxforth@gmail.com> once stated:

    Perhaps the TC went along with Mitch. CATCH THROW was his idea and
    here's a bunch of codes to go with it. The extent to which a tiny forth
    is going to use ANS is dubious.

    What constitutes a "tiny Forth"? Because I just implemented ANS Forth [1] for the 6809 [2], and I included CATCH and THROW. It's almost 12K in size
    and for the wordsets it implements, it passes the ANS Forth test suite. I implemented the EXCEPTION wordset because it seems a 2017 update mandated
    it's use. While I'm not a fan of exceptions, it wasn't hard to implement
    and it seemed better thought out than SYNONYM [4].

    -spc

    [1] I implemented CORE, CORE-EXT, DOUBLE, DOUBLE-EXT, EXCEPTION,
    EXCEPTION-EXT, LOCAL, LOCAL-EXT, TOOLS, some of TOOLS-EXT [3],
    SEARCH, SEARCH-EXT, STRING and STRING-EXT.

    [2] https://github.com/spc476/ANS-Forth

    [3] Words implemented from TOOLS-EXT: AHEAD, BYE, CS-PICK, CS_ROLL, N>R,
    NAME>COMPILE, NAME>INTERPRET, NAME>STRING, NR>, STATE,
    TRAVERSE-WORDLIST, [DEFINED], [ELSE], [IF], [THEN], [UNDEFINED].

    [4] When reading about it [5], I decided I didn't want anything to do
    with that quagmire of a word.

    [5] https://forth-standard.org/standard/tools/SYNONYM

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to dxforth@gmail.com on Thu Jun 5 12:12:34 2025
    In article <daf531f19ecb07c75994e9c0b371001c79f6929a@i2pn2.org>,
    dxf <dxforth@gmail.com> wrote:
    On 3/06/2025 4:10 pm, Anton Ertl wrote:
    dxf <dxforth@gmail.com> writes:
    ...
    But how much need today and what's wrong with ABORT"?

    My guess at the thinking behind the Forth-94 committee's decisions
    about that are:

    1) ABORT" Undefined word" takes more space than -13 AND THROW. Of
    course, if the system then has a table for translating throw codes
    to messages, that probably eliminates the memory savings, but a
    system that is really tight on memory can just output the error
    code and leave it to the user to look the error up in the manual.

    2) For CATCH, every ABORT" looks the same, so you cannot do something
    for one kind of error and something else for other kinds. Of
    course, the question is whether one can do that with the current
    situation (apparently not portably for inaccessible or non-existent
    files in INCLUDED), and whether that's something that Forth
    programmers would make use of if the situation was otherwise.

    Perhaps the TC went along with Mitch. CATCH THROW was his idea and
    here's a bunch of codes to go with it. The extent to which a tiny forth
    is going to use ANS is dubious. Having CATCH THROW just to pass compiler >errors is dubious. Compilers errors could be handled with ABORT" and two >characters (old-time BASIC users may remember).

    I added CATCH/THROW to figforth in creating ciforth.
    These are one liners and it saves a godawful code in other places.
    Especially if you ban ABORT" and its auxiliary words to the library.

    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to sean@conman.org on Thu Jun 5 12:17:11 2025
    In article <101q6ik$10htc$1@dont-email.me>, <sean@conman.org> wrote:
    It was thus said that the Great dxf <dxforth@gmail.com> once stated:

    Perhaps the TC went along with Mitch. CATCH THROW was his idea and
    here's a bunch of codes to go with it. The extent to which a tiny forth
    is going to use ANS is dubious.

    What constitutes a "tiny Forth"? Because I just implemented ANS Forth [1]
    for the 6809 [2], and I included CATCH and THROW. It's almost 12K in size >and for the wordsets it implements, it passes the ANS Forth test suite. I >implemented the EXCEPTION wordset because it seems a 2017 update mandated >it's use. While I'm not a fan of exceptions, it wasn't hard to implement
    and it seemed better thought out than SYNONYM [4].

    Good work, 12K is justly considered tiny.

    -spc

    [1] I implemented CORE, CORE-EXT, DOUBLE, DOUBLE-EXT, EXCEPTION,
    EXCEPTION-EXT, LOCAL, LOCAL-EXT, TOOLS, some of TOOLS-EXT [3],
    SEARCH, SEARCH-EXT, STRING and STRING-EXT.

    [2] https://github.com/spc476/ANS-Forth

    [3] Words implemented from TOOLS-EXT: AHEAD, BYE, CS-PICK, CS_ROLL, N>R,
    NAME>COMPILE, NAME>INTERPRET, NAME>STRING, NR>, STATE,
    TRAVERSE-WORDLIST, [DEFINED], [ELSE], [IF], [THEN], [UNDEFINED].

    [4] When reading about it [5], I decided I didn't want anything to do
    with that quagmire of a word.

    [5] https://forth-standard.org/standard/tools/SYNONYM

    You have included a lot of words that I considered not needed for
    a tiny Forth.
    The first time I will ever need CS-PICK I will add it to the library.
    It is not eligible for a kernel word.

    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From sean@conman.org@21:1/5 to It was thus on Fri Jun 6 06:15:53 2025
    It was thus said that the Great albert@spenarnc.xs4all.nl once stated:
    Good work, 12K is justly considered tiny.

    Thank you.

    [1] I implemented CORE, CORE-EXT, DOUBLE, DOUBLE-EXT, EXCEPTION,
    EXCEPTION-EXT, LOCAL, LOCAL-EXT, TOOLS, some of TOOLS-EXT [3],
    SEARCH, SEARCH-EXT, STRING and STRING-EXT.

    [2] https://github.com/spc476/ANS-Forth

    [3] Words implemented from TOOLS-EXT: AHEAD, BYE, CS-PICK, CS_ROLL, N>R, >> NAME>COMPILE, NAME>INTERPRET, NAME>STRING, NR>, STATE,
    TRAVERSE-WORDLIST, [DEFINED], [ELSE], [IF], [THEN], [UNDEFINED].

    [4] When reading about it [5], I decided I didn't want anything to do
    with that quagmire of a word.

    [5] https://forth-standard.org/standard/tools/SYNONYM

    You have included a lot of words that I considered not needed for
    a tiny Forth.

    Such as? One goal (which kind of went to the wayside as I was writing)
    was to use as much of standard Forth as possible to write the code (and less
    to implement in assembly), thus the inclusion of AHEAD, CS-ROLL, etc. But
    once I past 8K with pretty much CORE, CORE-EXT, SEARCH, SEARCH-EXT and the
    ones I was using from TOOLS-EXT, I had past 8K, so I decided I might as well include DOUBLE, DOUBLE-EXT, STRING, STRING-EXT, LOCAL and LOCAL-EXT. At
    that point, I might as well make a Forth that was useful for as many people
    as possible, while not locking it into a particular system. That's why I didn't bother with BLOCK, BLOCK-EXT, FACILITY or FACILITY-EXT (leaving that
    for the others to write for their system).

    The first time I will ever need CS-PICK I will add it to the library.
    It is not eligible for a kernel word.

    I wasn't sure if it was needed or not. It just falls pack to PICK anyway.

    -spc

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to sean@conman.org on Fri Jun 6 13:00:04 2025
    In article <101u12p$23a54$1@dont-email.me>, <sean@conman.org> wrote:
    It was thus said that the Great albert@spenarnc.xs4all.nl once stated:
    Good work, 12K is justly considered tiny.

    Thank you.

    [1] I implemented CORE, CORE-EXT, DOUBLE, DOUBLE-EXT, EXCEPTION,
    EXCEPTION-EXT, LOCAL, LOCAL-EXT, TOOLS, some of TOOLS-EXT [3],
    SEARCH, SEARCH-EXT, STRING and STRING-EXT.

    [2] https://github.com/spc476/ANS-Forth

    [3] Words implemented from TOOLS-EXT: AHEAD, BYE, CS-PICK, CS_ROLL, N>R, >>> NAME>COMPILE, NAME>INTERPRET, NAME>STRING, NR>, STATE,
    TRAVERSE-WORDLIST, [DEFINED], [ELSE], [IF], [THEN], [UNDEFINED].

    [4] When reading about it [5], I decided I didn't want anything to do
    with that quagmire of a word.

    [5] https://forth-standard.org/standard/tools/SYNONYM

    You have included a lot of words that I considered not needed for
    a tiny Forth.

    Such as? One goal (which kind of went to the wayside as I was writing)
    was to use as much of standard Forth as possible to write the code (and less >to implement in assembly), thus the inclusion of AHEAD, CS-ROLL, etc. But >once I past 8K with pretty much CORE, CORE-EXT, SEARCH, SEARCH-EXT and the >ones I was using from TOOLS-EXT, I had past 8K, so I decided I might as well >include DOUBLE, DOUBLE-EXT, STRING, STRING-EXT, LOCAL and LOCAL-EXT. At
    that point, I might as well make a Forth that was useful for as many people >as possible, while not locking it into a particular system. That's why I >didn't bother with BLOCK, BLOCK-EXT, FACILITY or FACILITY-EXT (leaving that >for the others to write for their system).

    Adding more wordsets is not making it useful for as many people as possible. Leaving out the FACILTY wordset ( SEE DUMP WORDS LOCATE) make a system virtually unusable.
    Using BLOCKS to store all words that belong in a library, that I found extremely
    useful. ( WANT ).
    Adding D2/ D2* D2> 2VARIABLE is in bad taste. They clutter up the output of WORDS. Try WORDS in gforth. Can you even check D2* is in there?
    Of course traditional formatting words require certain DOUBLE words.

    "as many people as possible" . My thought on this, to make it eminently
    usable by myself. What I did was writing hundreds of solution programs
    to Euler programs, instead of assuming that "more of the standard is better"


    The first time I will ever need CS-PICK I will add it to the library.
    It is not eligible for a kernel word.

    I wasn't sure if it was needed or not. It just falls pack to PICK anyway.

    You can be sure if you needs it, if you use your forth to program, not?


    -spc

    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From sean@conman.org@21:1/5 to It was thus on Fri Jun 6 21:06:51 2025
    It was thus said that the Great albert@spenarnc.xs4all.nl once stated:
    In article <101u12p$23a54$1@dont-email.me>, <sean@conman.org> wrote:

    Such as? One goal (which kind of went to the wayside as I was writing)
    was to use as much of standard Forth as possible to write the code (and less >to implement in assembly), thus the inclusion of AHEAD, CS-ROLL, etc. But >once I past 8K with pretty much CORE, CORE-EXT, SEARCH, SEARCH-EXT and the >ones I was using from TOOLS-EXT, I had past 8K, so I decided I might as well >include DOUBLE, DOUBLE-EXT, STRING, STRING-EXT, LOCAL and LOCAL-EXT. At >that point, I might as well make a Forth that was useful for as many people >as possible, while not locking it into a particular system. That's why I >didn't bother with BLOCK, BLOCK-EXT, FACILITY or FACILITY-EXT (leaving that >for the others to write for their system).

    Adding more wordsets is not making it useful for as many people as possible. Leaving out the FACILTY wordset ( SEE DUMP WORDS LOCATE) make a system virtually unusable.

    Um, FACILITY does not include SEE, DUMP, or WORDS, and LOCATE isn't in ANS Forth. They are in TOOLS, which I included (and SEE is the longest bit of
    code in my Forth).

    Using BLOCKS to store all words that belong in a library, that I found extremely
    useful. ( WANT ).

    Okay, what system should I support for BLOCKS? The Tandy Color Computer?
    The Dragon? OS-9? NitrOS? Flex? Fuzix? There are quite a few out there
    and I don't have access to all of them.

    Adding D2/ D2* D2> 2VARIABLE is in bad taste. They clutter up the output of WORDS. Try WORDS in gforth. Can you even check D2* is in there?
    Of course traditional formatting words require certain DOUBLE words.

    I have. And yes, it's a ton of words. A goal of my Forth system was to
    only have standard Forth words. Here's the output:

    UNESCAPE SUBSTITUTE REPLACES SLITERAL SEARCH COMPARE CMOVE> CMOVE BLANK
    /STRING -TRAILING PREVIOUS ORDER ONLY FORTH ALSO WORDLIST SET-ORDER
    SET-CURRENT SEARCH-WORDLIST GET-ORDER GET-CURRENT FORTH-WORDLIST FIND
    DEFINITIONS [UNDEFINED] [THEN] [IF] [ELSE] [DEFINED] TRAVERSE-WORDLIST
    STATE NR> NAME>STRING NAME>INTERPRET NAME>COMPILE N>R CS-ROLL CS-PICK BYE
    AHEAD WORDS SEE DUMP ? .S {: LOCALS| (LOCAL) ABORT" ABORT THROW CATCH DU<
    2VALUE 2ROT M+ M*/ DNEGATE DMIN DMAX DABS D>S D= D< D2/ D2* D0= D0< D.R D.
    D- D+ 2VARIABLE 2LITERAL 2CONSTANT \ [COMPILE] WITHIN VALUE UNUSED U> U.R
    TUCK TRUE TO SOURCE-ID SAVE-INPUT S\" ROLL RESTORE-INPUT REFILL PICK
    PARSE-NAME PARSE PAD OF NIP MARKER IS HOLDS HEX FALSE ERASE ENDOF ENDCASE
    DEFER@ DEFER! DEFER COMPILE, CASE C" BUFFER: AGAIN ACTION-OF ?DO <>
    :NONAME 2R@ 2R> 2>R 0> 0<> .R .( ] [CHAR] ['] [ XOR WORD WHILE VARIABLE
    UNTIL UNLOOP UM/MOD UM* U< U. TYPE THEN SWAP SPACES SPACE SOURCE SM/REM
    SIGN S>D S" RSHIFT ROT REPEAT RECURSE R@ R> QUIT POSTPONE OVER OR NEGATE
    MOVE MOD MIN MAX M* LSHIFT LOOP LITERAL LEAVE KEY J INVERT IMMEDIATE IF I
    HOLD HERE FM/MOD FILL EXIT EXECUTE EVALUATE ENVIRONMENT? EMIT ELSE DUP
    DROP DOES> DO DEPTH DECIMAL CREATE CR COUNT CONSTANT CHARS CHAR+ CHAR CELLS
    CELL+ C@ C, C! BL BEGIN BASE AND ALLOT ALIGNED ALIGN ACCEPT ABS @ ?DUP >R
    NUMBER >IN >BODY > = <# < ; : 2SWAP 2OVER 2DUP 2DROP 2@ 2/ 2* 2! 1- 1+ 0=
    0< /MOD / ." . - , +LOOP +! + */MOD */ * ( ' #S #> # !

    I wasn't sure if it was needed or not. It just falls pack to PICK anyway.

    You can be sure if you needs it, if you use your forth to program, not?

    I have XOR, but I've yet to use it. Should I not have included that one?

    -spc

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From sean@conman.org@21:1/5 to It was thus on Sat Jun 7 04:26:12 2025
    It was thus said that the Great dxf <dxforth@gmail.com> once stated:
    On 7/06/2025 7:06 am, sean@conman.org wrote:
    ...
    A goal of my Forth system was to only have standard Forth words.

    You trust the Standard. Why?

    Why not? This was a learning experience for me, as this is my first
    actual Forth implementation [1]. The ANS Forth 2012 standard gave me a
    target to aim for. Guess I shouldn't have bothered then.

    The Standard dates backs to 1977 starting out as
    a list of words pulled from Kitt Peak Forth. If KPF didn't have (.) etc well that was just too bad. The point being nobody sat down and systematically designed the standard (or forth) ground up. It was adhoc. It's always been adhoc. Moore has changed his mind numerous times. What one sees in the Standard
    is a snapshot of 1977.

    It seems to have concepts that have occured after 1977, or are you
    speaking of some other Forth Standard, like 79 or 83?

    Even small forths can do better than what the standard offers by simply factoring
    out tools already present e.g.

    (.) (D.) (U.) /CHAR >CHAR >DIGIT HELD MU* MU/MOD TRIM UNNEST

    I'd rather have these than all the support for wordlists DEFER and other stuff
    the standard and folks have obsessed over.

    Can you not implement them with ANS Forth?

    -spc

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to sean@conman.org on Sat Jun 7 09:43:56 2025
    sean@conman.org writes:
    Why not? This was a learning experience for me, as this is my first
    actual Forth implementation [1]. The ANS Forth 2012 standard gave me a >target to aim for. Guess I shouldn't have bothered then.

    Don't let the usual naysayers discourage you. You took your choices,
    based on reasonable criteria, and you finished what you set out to do.
    Great!

    The Standard dates backs to 1977 starting out as
    a list of words pulled from Kitt Peak Forth. If KPF didn't have (.) etc well
    that was just too bad. The point being nobody sat down and systematically >> designed the standard (or forth) ground up. It was adhoc. It's always been >> adhoc. Moore has changed his mind numerous times. What one sees in the Standard
    is a snapshot of 1977.

    It seems to have concepts that have occured after 1977, or are you
    speaking of some other Forth Standard, like 79 or 83?

    The cool thing about dxf is that he always criticizes the standard,
    usually for innovations that he denounces as deviations from
    traditional Forth values. Criticizing the standard because of its
    ancestry is a new twist in his postings.

    Even small forths can do better than what the standard offers by simply factoring
    out tools already present e.g.

    (.) (D.) (U.) /CHAR >CHAR >DIGIT HELD MU* MU/MOD TRIM UNNEST

    I'd rather have these than all the support for wordlists DEFER and other stuff
    the standard and folks have obsessed over.

    That's the more usual stance that dxf takes.

    Can you not implement them with ANS Forth?

    He claims that these are already present in existing implementations,
    only not standardized. For (.) (D.) (U.) that's certainly not the
    case in Gforth. As for /CHAR >CHAR >DIGIT HELD MU* MU/MOD TRIM
    UNNEST, I don't know what they are supposed to do, so I cannot tell
    whether Gforth has some factors that correspond to them.

    - 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 2023 proceedings: http://www.euroforth.org/ef23/papers/
    EuroForth 2024 proceedings: http://www.euroforth.org/ef24/papers/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Paul Rubin@21:1/5 to dxf on Sat Jun 7 12:58:51 2025
    dxf <dxforth@gmail.com> writes:
    For (.) (D.) (U.) that's certainly not the case in Gforth.
    I said the Standard hadn't factored them out. Several forths of course
    have factored them out.

    Well I think you were saying the standard SHOULD have factored them out, presumably because they are both useful to users, and reasonably
    necessary parts of the underlying implementation that could have been
    exported, as opposed to just giving more clutter for implementers to
    supply.

    So now I have to also wonder what they do and what they are good for.

    As for /CHAR >CHAR >DIGIT HELD MU* MU/MOD TRIM UNNEST

    Same for these. I can sort of guess at a few.

    --- 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 Sun Jun 8 01:31:58 2025
    In article <87plff4938.fsf@nightsong.com>,
    Paul Rubin <no.email@nospam.invalid> wrote:
    dxf <dxforth@gmail.com> writes:
    For (.) (D.) (U.) that's certainly not the case in Gforth.
    I said the Standard hadn't factored them out. Several forths of course
    have factored them out.

    Well I think you were saying the standard SHOULD have factored them out, >presumably because they are both useful to users, and reasonably
    necessary parts of the underlying implementation that could have been >exported, as opposed to just giving more clutter for implementers to
    supply.

    It is occasionally useful to have conversions to a string that
    not immediately prints. Even figforth had a (D.R) that was a
    D.R without the type.
    But thanks to the #-set a conversion is very short :
    : (.) 0 <# #S #> ;
    I tend to define such word in the application , otherwise you end up
    adding (.) (U.) (D.) (UD.) (D.R) to the standard.




    So now I have to also wonder what they do and what they are good for.

    As for /CHAR >CHAR >DIGIT HELD MU* MU/MOD TRIM UNNEST

    Same for these. I can sort of guess at a few.

    People tend to use additions and forget that they are not standardized,
    making programs unreadable and/or unusable.

    I prefer specifying library functions that are used as source and
    can be looked up as source, and if need be can be added to the application
    if porting.

    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Paul Rubin@21:1/5 to albert@spenarnc.xs4all.nl on Sat Jun 7 18:49:02 2025
    albert@spenarnc.xs4all.nl writes:
    : (.) 0 <# #S #> ;

    I see, it converts a number to a string. I guess if you have <# #S #>
    then that is easy enough. Otherwise it depends on how . is implemented.

    I wonder if there's a standard or well known way to capture the output
    of . and related words, like redirecting the input stream.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to albert@spenarnc.xs4all.nl on Sun Jun 8 07:56:26 2025
    albert@spenarnc.xs4all.nl writes:
    In article <87plff4938.fsf@nightsong.com>,
    Paul Rubin <no.email@nospam.invalid> wrote:
    dxf <dxforth@gmail.com> writes:
    For (.) (D.) (U.) that's certainly not the case in Gforth.
    I said the Standard hadn't factored them out. Several forths of course
    have factored them out.

    Well I think you were saying the standard SHOULD have factored them out, >>presumably because they are both useful to users, and reasonably
    necessary parts of the underlying implementation that could have been >>exported, as opposed to just giving more clutter for implementers to >>supply.

    It is occasionally useful to have conversions to a string that
    not immediately prints. Even figforth had a (D.R) that was a
    D.R without the type.

    It's not in the fig-Forth Installation Manual / Glossary / Model Release !

    http://wiki.yak.net/1089/fig-FORTH_Manuals_May79.pdf

    nor in the source code.

    https://raw.githubusercontent.com/ForthHub/FIG-Forth/refs/heads/master/fig.fth

    But thanks to the #-set a conversion is very short :
    : (.) 0 <# #S #> ;
    I tend to define such word in the application , otherwise you end up
    adding (.) (U.) (D.) (UD.) (D.R) to the standard.

    Your (.) looks more like (U.) to me.

    Alternatively, add

    >string-execute ( ... xt – ... c-addr u ) gforth-1.0 "to-string-execute"

    Execute xt while the standard output (type, emit, and everything that
    uses them) is redirected to a string. The resulting string is c-addr
    u, which is in heap memory; it is the responsibility of the caller of
    >string-execute to free this string.

    Then you can do

    ' d.r >string-execute

    instead. This approach has some overhead, however.

    - 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 2023 proceedings: http://www.euroforth.org/ef23/papers/
    EuroForth 2024 proceedings: http://www.euroforth.org/ef24/papers/

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Anton Ertl@21:1/5 to Paul Rubin on Sun Jun 8 08:07:14 2025
    Paul Rubin <no.email@nospam.invalid> writes:
    I wonder if there's a standard or well known way to capture the output
    of . and related words, like redirecting the input stream.

    In some systems TYPE and EMIT are a deferred words. So I can do

    : no-output-execute ( ... xt -- ... )
    action-of type action-of emit 2>r
    ['] 2drop is type ['] drop is emit catch
    2r> is emit is type
    throw ;

    ." |" 5 ' . no-output-execute ." |"

    This works in Gforth and in VFX64.

    SwiftForth has a system (personalities) for vectoring a number of I/O
    words, including TYPE. So the code above does not work in SwiftForth,
    but you can define a personality to achieve the same thing. LOCATE SIMPLE-BUFFERING in SwiftForth to see how a personality is defined.

    Gforth actually gives you both worlds: TYPE is a defer-flavoured field
    in a method table accessed through a user variable. So you can define
    such a table (with OUTPUT:) and use it for changing the output, or you
    can do the quick-and-dirty approach of revectoring the individual
    words shown above.

    However, if you actually want to have the result in a string, you also
    need to manage a buffer such that consecutive calls to TYPE and EMIT
    are concatenated. In Gforth, >STRING-EXECUTE does all that for you.
    You only have to FREE the buffer once you are done with it.

    - 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 2023 proceedings: http://www.euroforth.org/ef23/papers/
    EuroForth 2024 proceedings: http://www.euroforth.org/ef24/papers/

    --- 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 Sun Jun 8 13:34:03 2025
    In article <87ldq33svl.fsf@nightsong.com>,
    Paul Rubin <no.email@nospam.invalid> wrote:
    albert@spenarnc.xs4all.nl writes:
    : (.) 0 <# #S #> ;

    I see, it converts a number to a string. I guess if you have <# #S #>
    then that is easy enough. Otherwise it depends on how . is implemented.

    I hope you realize that <# # #S #> are CORE words. You are hard pressed to
    find a Forth that doesn't have those.


    I wonder if there's a standard or well known way to capture the output
    of . and related words, like redirecting the input stream.

    Probably there is, revectoring EMIT and forcing the Forth to work
    with single characters. Anton Ertl can show how it is done with
    gforth.

    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to Anton Ertl on Sun Jun 8 13:51:00 2025
    In article <2025Jun8.095626@mips.complang.tuwien.ac.at>,
    Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
    albert@spenarnc.xs4all.nl writes:

    It is occasionally useful to have conversions to a string that
    not immediately prints. Even figforth had a (D.R) that was a
    D.R without the type.

    It's not in the fig-Forth Installation Manual / Glossary / Model Release !

    http://wiki.yak.net/1089/fig-FORTH_Manuals_May79.pdf

    nor in the source code.

    https://raw.githubusercontent.com/ForthHub/FIG-Forth/refs/heads/master/fig.fth

    I should have known better. https://home.hccnet.nl/a.w.m.van.der.horst/figdoc.zip
    I remembered the way D. was reduced in the code to
    D.R and confused the two mechanisms.

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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From albert@spenarnc.xs4all.nl@21:1/5 to dxforth@gmail.com on Mon Jun 9 12:49:10 2025
    In article <15f0ff69ffcb0b25a08cace9d19b8b8522a828b1@i2pn2.org>,
    dxf <dxforth@gmail.com> wrote:
    On 8/06/2025 9:51 pm, albert@spenarnc.xs4all.nl wrote:
    In article <2025Jun8.095626@mips.complang.tuwien.ac.at>,
    Anton Ertl <anton@mips.complang.tuwien.ac.at> wrote:
    albert@spenarnc.xs4all.nl writes:

    It is occasionally useful to have conversions to a string that
    not immediately prints. Even figforth had a (D.R) that was a
    D.R without the type.

    It's not in the fig-Forth Installation Manual / Glossary / Model Release ! >>>
    http://wiki.yak.net/1089/fig-FORTH_Manuals_May79.pdf

    nor in the source code.

    https://raw.githubusercontent.com/ForthHub/FIG-Forth/refs/heads/master/fig.fth

    I should have known better.
    https://home.hccnet.nl/a.w.m.van.der.horst/figdoc.zip
    I remembered the way D. was reduced in the code to
    D.R and confused the two mechanisms.

    It's probably easier to justify (D.) than (D.R). If one needs to right-justify
    numbers, chances are one will need to right-justify non-numeric strings as well.
    For this reason I have S.R in the kernel and (S.R) as a library function.


    (D.) is a good addition to a kernel. In 2023 it was added to ciforth's kernel. This honour is bestowed on less than half a dozen words since 2002 version 4.0.,
    demonstrating that fig-forth was nearly perfect. Other words are NIP and $\ .

    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.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Paul Rubin@21:1/5 to albert@spenarnc.xs4all.nl on Tue Jun 10 14:11:30 2025
    albert@spenarnc.xs4all.nl writes:
    Probably there is, revectoring EMIT and forcing the Forth to work
    with single characters. Anton Ertl can show how it is done with
    gforth.

    Yes, but it seems to be implementation specific. Reasonable point about
    <#... being in CORE. It always seemed to me that those words should
    have been in an extension.

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