Re: THROW codes and ambiguous conditions

Liste des GroupesRevenir à cl forth 
Sujet : Re: THROW codes and ambiguous conditions
De : anton (at) *nospam* mips.complang.tuwien.ac.at (Anton Ertl)
Groupes : comp.lang.forth
Date : 03. Jun 2025, 07:10:34
Autres entêtes
Organisation : Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID : <2025Jun3.081034@mips.complang.tuwien.ac.at>
References : 1 2 3 4 5
User-Agent : xrn 10.11
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/

Date Sujet#  Auteur
31 May 25 * THROW codes and ambiguous conditions37dxf
31 May 25 +* Re: THROW codes and ambiguous conditions7Anton Ertl
31 May 25 i+* Re: THROW codes and ambiguous conditions2dxf
3 Jun21:48 ii`- Re: THROW codes and ambiguous conditions1sjack
31 May 25 i`* Re: THROW codes and ambiguous conditions4Anton Ertl
1 Jun 25 i `* Re: THROW codes and ambiguous conditions3albert
1 Jun 25 i  `* Re: THROW codes and ambiguous conditions2Anton Ertl
1 Jun 25 i   `- Re: THROW codes and ambiguous conditions1albert
1 Jun 25 `* Re: THROW codes and ambiguous conditions29Hans Bezemer
2 Jun 25  +- Re: THROW codes and ambiguous conditions1dxf
2 Jun11:44  `* Re: THROW codes and ambiguous conditions27albert
3 Jun04:23   `* Re: THROW codes and ambiguous conditions26dxf
3 Jun07:10    +* Re: THROW codes and ambiguous conditions22Anton Ertl
4 Jun15:44    i`* Re: THROW codes and ambiguous conditions21dxf
4 Jun20:25    i `* Re: THROW codes and ambiguous conditions20sean
5 Jun07:09    i  +- Re: THROW codes and ambiguous conditions1dxf
5 Jun11:17    i  `* Re: THROW codes and ambiguous conditions18albert
6 Jun01:47    i   +- Re: THROW codes and ambiguous conditions1dxf
6 Jun07:15    i   `* Re: THROW codes and ambiguous conditions16sean
6 Jun12:00    i    `* Re: THROW codes and ambiguous conditions15albert
6 Jun22:06    i     `* Re: THROW codes and ambiguous conditions14sean
7 Jun04:10    i      `* Re: THROW codes and ambiguous conditions13dxf
7 Jun05:26    i       `* Re: THROW codes and ambiguous conditions12sean
7 Jun05:42    i        +- Re: THROW codes and ambiguous conditions1dxf
7 Jun10:43    i        +* Re: THROW codes and ambiguous conditions9Anton Ertl
7 Jun15:06    i        i`* Re: THROW codes and ambiguous conditions8dxf
7 Jun20:58    i        i `* Re: THROW codes and ambiguous conditions7Paul Rubin
8 Jun02:49    i        i  +* Re: THROW codes and ambiguous conditions3Paul Rubin
8 Jun04:36    i        i  i+- Re: THROW codes and ambiguous conditions1dxf
8 Jun09:07    i        i  i`- Re: THROW codes and ambiguous conditions1Anton Ertl
8 Jun03:16    i        i  +- Re: THROW codes and ambiguous conditions1dxf
8 Jun08:56    i        i  `* Re: THROW codes and ambiguous conditions2Anton Ertl
8 Jun15:45    i        i   `- Re: THROW codes and ambiguous conditions1dxf
7 Jun15:41    i        `- Re: THROW codes and ambiguous conditions1LIT
3 Jun09:43    +- Re: THROW codes and ambiguous conditions1John
4 Jun03:03    `* Re: THROW codes and ambiguous conditions2dxf
6 Jun11:47     `- Re: THROW codes and ambiguous conditions1Hans Bezemer

Haut de la page

Les messages affichés proviennent d'usenet.

NewsPortal