Deutsch   English   Français   Italiano  
<2025May1.185348@mips.complang.tuwien.ac.at>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder9.news.weretis.net!news.quux.org!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail
From: anton@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Why dial-a-standard is not a thing in Forth
Date: Thu, 01 May 2025 16:53:48 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 60
Message-ID: <2025May1.185348@mips.complang.tuwien.ac.at>
References: <87bjtn2hct.fsf@gmail.com> <7aa5519d5cb072cb6f70e7680ec565b03c2f3e23@i2pn2.org> <nnd$3b017059$6aa9c908@b5507bbc6e704cf6> <5ce2cb85311aa91fcb7ab57c802aef09b3345163@i2pn2.org> <vuvl87$2i8nl$1@dont-email.me>
Injection-Date: Thu, 01 May 2025 19:14:13 +0200 (CEST)
Injection-Info: dont-email.me; posting-host="427d029904597ec99b682a562a944d6b";
	logging-data="3272548"; mail-complaints-to="abuse@eternal-september.org";	posting-account="U2FsdGVkX1935wn4x4m/gzd55r/SNv10"
Cancel-Lock: sha1:NO7vZpedyvsjGfJI06rXZYjCnm8=
X-newsreader: xrn 10.11
Bytes: 3160

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