Sujet : Re: Why dial-a-standard is not a thing in Forth
De : anton (at) *nospam* mips.complang.tuwien.ac.at (Anton Ertl)
Groupes : comp.lang.forthDate : 01. May 2025, 17:53:48
Autres entêtes
Organisation : Institut fuer Computersprachen, Technische Universitaet Wien
Message-ID : <2025May1.185348@mips.complang.tuwien.ac.at>
References : 1 2 3 4 5
User-Agent : xrn 10.11
John Doe <
john.doe@myemail.invalid> writes:
In VFX, the return to the text interpreter looks for a message associated with
the throw number and displays it if found.
>
There are three benefits of this.
1) it is less code to reuse a THROW by number rather than by text,
2) I can change the text in one place only for all uses,
Moreover, it ensures that a specific throw code is associated with a
specific error message (rather than having different messages for the
same throw code). Gforth gives you a way to get a previously
unoccupied throw code and associate an error message with it:
s" Completely unheard-of condition" exception constant WTF
WTF throw
This outputs:
*the terminal*:4:5: error: Completely unheard-of condition
WTF >>>throw<<<
But you can also catch this condition
: handle-WTF ( xt )
catch dup WTF = if 2drop ." recovering from WTF" 0 then
throw ;
WTF ' throw handle-WTF \ output: "recovering from WTF ok"
3) Internationalisartion is much easier.
True, but I find it more useful not to have internationalized error
messages. I can search for the error message in the WWW, and then
find more pages (and hopefully a relevant one) than if I use a
localized error message. However, some error messages are inherited
from other layers, so if you use a non-English-language locale, Gforth
gives you localized stuff:
[~/gforth:157334] LANG=de_AT.utf8 gforth
Gforth 0.7.9_20250409
...
include sdfl
*the terminal*:1:9: error: Datei oder Verzeichnis nicht gefunden
include >>>sdfl<<<
...
But at least the messages coming from the Forth level are not
localized:
0 @
*the terminal*:2:3: error: Invalid memory address
0 >>>@<<<
- anton
-- M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.htmlcomp.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/