Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

I just thought of something funny...your mother. -- Cheech Marin


devel / comp.lang.forth / Re: Existing ior practice

SubjectAuthor
* Existing ior practiceAnton Ertl
+* Re: Existing ior practiceminf...@arcor.de
|+* Re: Existing ior practiceKrishna Myneni
||+* Re: Existing ior practiceminf...@arcor.de
|||+* Re: Existing ior practiceBernd Linsel
||||`- Re: Existing ior practiceNickolay Kolchin
|||`- Re: Existing ior practiceKrishna Myneni
||`* Re: Existing ior practiceAnton Ertl
|| `* Re: Existing ior practiceminf...@arcor.de
||  `- Re: Existing ior practicedxforth
|`- Re: Existing ior practiceAnton Ertl
+- Re: Existing ior practiceKrishna Myneni
+* Re: Existing ior practiceRuvim
|`* Re: Existing ior practicedxforth
| +* Re: Existing ior practiceRuvim
| |+* Re: Existing ior practicedxforth
| ||`* Re: Existing ior practiceRuvim
| || `* Re: Existing ior practiceAnton Ertl
| ||  +- Re: Existing ior practiceRuvim
| ||  `* Re: Existing ior practiceRuvim
| ||   `* Re: Existing ior practiceAnton Ertl
| ||    `* Re: Existing ior practiceRuvim
| ||     +- Re: Existing ior practiceRuvim
| ||     +* Re: Existing ior practicedxforth
| ||     |`* Re: Existing ior practiceRuvim
| ||     | `* Re: Existing ior practicedxforth
| ||     |  `* Re: Existing ior practiceRuvim
| ||     |   `* Re: Existing ior practicedxforth
| ||     |    `* Re: Existing ior practiceRuvim
| ||     |     +* Re: Existing ior practiceS Jack
| ||     |     |+- Re: Existing ior practiceS Jack
| ||     |     |`- Re: Existing ior practiceS Jack
| ||     |     `* Re: Existing ior practicedxforth
| ||     |      `* Re: Existing ior practiceRuvim
| ||     |       `* Re: Existing ior practicedxforth
| ||     |        `* Re: Existing ior practiceRuvim
| ||     |         `- Re: Existing ior practicedxforth
| ||     `* Re: Existing ior practiceAnton Ertl
| ||      `- Re: Existing ior practiceRuvim
| |`* Re: Existing ior practiceAnton Ertl
| | +* Re: Existing ior practiceRuvim
| | |`- Re: Existing ior practicedxforth
| | +* Re: Existing ior practiceStephen Pelc
| | |`* Re: Existing ior practiceAnton Ertl
| | | `- Re: Existing ior practicedxforth
| | `* How to avoid collisions of throw codes (was: Existing ior practice)Ruvim
| |  `* Re: How to avoid collisions of throw codes (was: Existing ior practice)Anton Ertl
| |   `* Re: How to avoid collisions of throw codes (was: Existing iorRuvim
| |    `- Re: How to avoid collisions of throw codes (was: Existing iorRuvim
| `- Re: Existing ior practiceAnton Ertl
+- Re: Existing ior practicedxforth
`- Re: Existing ior practiceHans Bezemer

Pages:123
Re: Existing ior practice

<srehpt$s28$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16235&group=comp.lang.forth#16235

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: step...@vfxforth.com (Stephen Pelc)
Newsgroups: comp.lang.forth
Subject: Re: Existing ior practice
Date: Sun, 9 Jan 2022 11:43:57 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <srehpt$s28$1@dont-email.me>
References: <2022Jan7.125232@mips.complang.tuwien.ac.at> <srajop$vmc$1@dont-email.me> <sram42$1kes$1@gioia.aioe.org> <srbg47$v6g$1@dont-email.me> <2022Jan8.112141@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=fixed
Content-Transfer-Encoding: 8bit
Injection-Date: Sun, 9 Jan 2022 11:43:57 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="33bb06170191c733d5a4ec70d390709b";
logging-data="28744"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18xXhiwu5wLf3P6tQaMi3a1"
User-Agent: Usenapp/1.17/l for MacOS - Full License
Cancel-Lock: sha1:41lJKpdfCMP7sl4EWOw0mBC3muw=
 by: Stephen Pelc - Sun, 9 Jan 2022 11:43 UTC

On 8 Jan 2022 at 11:21:41 CET, "Anton Ertl" <Anton Ertl> wrote:
>
> Yes: Checking iForth, lxf, SwiftForth, and VFX, none of them has
> picked up EXCEPTION. This is probably because need for defining throw
> codes in libraries is rare, and I guess the low importance of
> libraries in Forth also plays a role. Anyway, if you want to write a
> library for Gforth, Gforth has had EXCEPTION since at least 1998.

The reason why we ignored EXCEPTION was that it did not do what we
wanted. VFX provides ERRDEF and friends.

ERRDEF <name> "<text>" \ -- n

At compile time this generates a CONSTANT called <name> associated
with the text for THROW number n. The constant n is incremented for the
next use of ERRDEF. There are variants of ERRDEF that take a value and
SYSERRDEF generates a number in the range -1..-4095.

These have been in VFX since v3.6.

Stephen

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

Re: Existing ior practice

<2022Jan9.183919@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16237&group=comp.lang.forth#16237

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Existing ior practice
Date: Sun, 09 Jan 2022 17:39:19 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 40
Message-ID: <2022Jan9.183919@mips.complang.tuwien.ac.at>
References: <2022Jan7.125232@mips.complang.tuwien.ac.at> <srajop$vmc$1@dont-email.me> <sram42$1kes$1@gioia.aioe.org> <srbg47$v6g$1@dont-email.me> <srbip9$131d$1@gioia.aioe.org> <srbku8$puh$1@dont-email.me> <2022Jan8.115507@mips.complang.tuwien.ac.at> <srcrap$q96$1@dont-email.me>
Injection-Info: reader02.eternal-september.org; posting-host="ac1f63466b2b9994d280e680ff22633d";
logging-data="7913"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19UGYV1rZITtVyolQa6ZJsI"
Cancel-Lock: sha1:jUZ1hq/xxmrRVYYk6qwULWw9sMg=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sun, 9 Jan 2022 17:39 UTC

Ruvim <ruvim.pinka@gmail.com> writes:
>On 2022-01-08 13:55, Anton Ertl wrote:
>> I don't know what dxforth means, but there is such a difference: A
>> library that is provided independent of systems cannot know what throw
>> codes are used by the system, and so has to define throw codes outside
>> the -4095..0 range. OTOH, a library that is provided by the system
>> implementor for a specific system can know which throw codes the
>> system uses and in that case the lowest collision risk is if the
>> library uses throw codes in the -4095..-1 range that are not used by
>> anything else in the system (nor any other system library).
>
>
>Does it mean that if some vendor includes some portable library into its
>system, it should also change the throw codes in this library to the
>-4095..-256 range?

That would be ideal for eliminating collision risks, but the fact that
we are considering such measures points to a lack in the Forth
standard.

>> As an example, the version of EXCEPTION in the compat library uses
>> numbers outside the -4095..-1 range, while the version of EXCEPTION
>> built into Gforth uses numbers inside that range.
>
>So a third-party library should not use the built-in EXCEPTION word when
>it runs in Gforth to avoid -4095..-1 range, should it?

No, using the built-in exception is a good idea? In your scenario the
third-party library gets the throw code from a system word instead of
defining it itself, and of course using that throw code is perfectly
safe. It knows how to avoid collisions with Gforth's built-in throw
codes, and avoids collisions with user-defined throw codes by using
numbers in the -4095..-1 range.

- 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: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: Existing ior practice

<2022Jan9.190108@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16239&group=comp.lang.forth#16239

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Existing ior practice
Date: Sun, 09 Jan 2022 18:01:08 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 45
Message-ID: <2022Jan9.190108@mips.complang.tuwien.ac.at>
References: <2022Jan7.125232@mips.complang.tuwien.ac.at> <srajop$vmc$1@dont-email.me> <sram42$1kes$1@gioia.aioe.org> <srbg47$v6g$1@dont-email.me> <2022Jan8.112141@mips.complang.tuwien.ac.at> <srehpt$s28$1@dont-email.me>
Injection-Info: reader02.eternal-september.org; posting-host="ac1f63466b2b9994d280e680ff22633d";
logging-data="7913"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+P0iRGrvE29czqKGkJDyBe"
Cancel-Lock: sha1:ax7jwHzNj9r/9Vgv6BoKL4Su+Us=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Sun, 9 Jan 2022 18:01 UTC

Stephen Pelc <stephen@vfxforth.com> writes:
>On 8 Jan 2022 at 11:21:41 CET, "Anton Ertl" <Anton Ertl> wrote:
>>
>> Yes: Checking iForth, lxf, SwiftForth, and VFX, none of them has
>> picked up EXCEPTION. This is probably because need for defining throw
>> codes in libraries is rare, and I guess the low importance of
>> libraries in Forth also plays a role. Anyway, if you want to write a
>> library for Gforth, Gforth has had EXCEPTION since at least 1998.
>
>The reason why we ignored EXCEPTION was that it did not do what we
>wanted. VFX provides ERRDEF and friends.
>
>ERRDEF <name> "<text>" \ -- n
>
>At compile time this generates a CONSTANT called <name> associated
>with the text for THROW number n.

So instead of writing

s" my error message" exception constant mythrowcode

you write

errdef mythrowcode "my error message"

I don't see why you do not add EXCEPTION as factor of ERRDEF. NIH?

>The constant n is incremented for the
>next use of ERRDEF. There are variants of ERRDEF that take a value and
>SYSERRDEF generates a number in the range -1..-4095.

ERRDEF starts at 509 in VFX Forth 64 5.11 RC2, which has the risk of
colliding with user-defined throw codes. So better ignore ERRDEF and
use SYSERRDEF.

>These have been in VFX since v3.6.

Looking at VFX release notes, that was in 2003.

- 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: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: Existing ior practice

<srg0a0$1e26$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16245&group=comp.lang.forth#16245

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Existing ior practice
Date: Mon, 10 Jan 2022 11:57:35 +1100
Organization: Aioe.org NNTP Server
Message-ID: <srg0a0$1e26$1@gioia.aioe.org>
References: <2022Jan7.125232@mips.complang.tuwien.ac.at>
<srajop$vmc$1@dont-email.me> <sram42$1kes$1@gioia.aioe.org>
<srbg47$v6g$1@dont-email.me> <2022Jan8.112141@mips.complang.tuwien.ac.at>
<srehpt$s28$1@dont-email.me> <2022Jan9.190108@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="47174"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.4.1
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Mon, 10 Jan 2022 00:57 UTC

On 10/01/2022 05:01, Anton Ertl wrote:
> Stephen Pelc <stephen@vfxforth.com> writes:
>>On 8 Jan 2022 at 11:21:41 CET, "Anton Ertl" <Anton Ertl> wrote:
>>>
>>> Yes: Checking iForth, lxf, SwiftForth, and VFX, none of them has
>>> picked up EXCEPTION. This is probably because need for defining throw
>>> codes in libraries is rare, and I guess the low importance of
>>> libraries in Forth also plays a role. Anyway, if you want to write a
>>> library for Gforth, Gforth has had EXCEPTION since at least 1998.
>>
>>The reason why we ignored EXCEPTION was that it did not do what we
>>wanted. VFX provides ERRDEF and friends.
>>
>>ERRDEF <name> "<text>" \ -- n
>>
>>At compile time this generates a CONSTANT called <name> associated
>>with the text for THROW number n.
>
> So instead of writing
>
> s" my error message" exception constant mythrowcode
>
> you write
>
> errdef mythrowcode "my error message"
>
> I don't see why you do not add EXCEPTION as factor of ERRDEF. NIH?
>
>>The constant n is incremented for the
>>next use of ERRDEF. There are variants of ERRDEF that take a value and
>>SYSERRDEF generates a number in the range -1..-4095.
>
> ERRDEF starts at 509 in VFX Forth 64 5.11 RC2, which has the risk of
> colliding with user-defined throw codes. So better ignore ERRDEF and
> use SYSERRDEF.
>
>>These have been in VFX since v3.6.
>
> Looking at VFX release notes, that was in 2003.

It's saying Standard Forth is no closer to being a computing language
than it was in 2003. Indeed, I'm increasingly loathe to call Forth a
'computing language' at all because it doesn't meet the criteria most
people expect of one. The term Moore used to describe Forth was "toolkit"
- which is at least honest. That's not to say an individual Forth
implementation couldn't become a well-designed 'language'. What's for
sure is Standard Forth will never be one - not least because members are
determined to keep their own. If Standard Forth has achieved it has
been in the language of compromise and appeasement - not computing.

Re: Existing ior practice

<srh1tg$h8s$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16253&group=comp.lang.forth#16253

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ruvim.pi...@gmail.com (Ruvim)
Newsgroups: comp.lang.forth
Subject: Re: Existing ior practice
Date: Mon, 10 Jan 2022 13:31:11 +0300
Organization: A noiseless patient Spider
Lines: 88
Message-ID: <srh1tg$h8s$1@dont-email.me>
References: <2022Jan7.125232@mips.complang.tuwien.ac.at>
<srajop$vmc$1@dont-email.me> <sram42$1kes$1@gioia.aioe.org>
<srbg47$v6g$1@dont-email.me> <srbip9$131d$1@gioia.aioe.org>
<srbku8$puh$1@dont-email.me> <2022Jan8.115507@mips.complang.tuwien.ac.at>
<srcrap$q96$1@dont-email.me> <2022Jan9.183919@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 10 Jan 2022 10:31:13 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="7f23104408f5b07f9378fe974542ad6e";
logging-data="17692"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+cNET/LTvhXkjI8NdzHPoE"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.4.1
Cancel-Lock: sha1:JuGlfg4ybutp8XpKv3g6dCsg8cs=
In-Reply-To: <2022Jan9.183919@mips.complang.tuwien.ac.at>
Content-Language: en-US
 by: Ruvim - Mon, 10 Jan 2022 10:31 UTC

On 2022-01-09 20:39, Anton Ertl wrote:
> Ruvim <ruvim.pinka@gmail.com> writes:
>> On 2022-01-08 13:55, Anton Ertl wrote:
>>> I don't know what dxforth means, but there is such a difference: A
>>> library that is provided independent of systems cannot know what throw
>>> codes are used by the system, and so has to define throw codes outside
>>> the -4095..0 range. OTOH, a library that is provided by the system
>>> implementor for a specific system can know which throw codes the
>>> system uses and in that case the lowest collision risk is if the
>>> library uses throw codes in the -4095..-1 range that are not used by
>>> anything else in the system (nor any other system library).
>>
>>
>> Does it mean that if some vendor includes some portable library into its
>> system, it should also change the throw codes in this library to the
>> -4095..-256 range?
>
> That would be ideal for eliminating collision risks, but the fact that
> we are considering such measures points to a lack in the Forth
> standard.

Yes, this lack exists, of course. It is just not too critical at the moment.

>>> As an example, the version of EXCEPTION in the compat library uses
>>> numbers outside the -4095..-1 range, while the version of EXCEPTION
>>> built into Gforth uses numbers inside that range.
>>
>> So a third-party library should not use the built-in EXCEPTION word when
>> it runs in Gforth to avoid -4095..-1 range, should it?
>
> No, using the built-in exception is a good idea? In your scenario the
> third-party library gets the throw code from a system word instead of
> defining it itself, and of course using that throw code is perfectly
> safe. It knows how to avoid collisions with Gforth's built-in throw
> codes, and avoids collisions with user-defined throw codes by using
> numbers in the -4095..-1 range.

Then it's as if this third-party library becomes a part of the system.

And what about a program? May it use the built-in "EXCEPTION"? If yes,
then it formally violates the restriction on programs (albeit it's
totally safe).

Concerning the "EXCEPTION" word as an API. This word has two functions:
reserve a throw code, and associate a textual message with this code.

Probably in a basic API these functions should be disjointed. And a
general method to retrieve a message by a throw code should be a part of
this API too.

Also, an interesting thing is a method to retrieve a throw number by a
message. Having such a method, something similar to my "sthrow" can be
defined. The key idea is that you don't need to declare exceptions
beforehand, but just use them on the fly.

\ message-by-code? ( n -- sd.message true | n false )
\ code-by-message? ( sd.message -- n true | sd.message false )

: obtain-code-by-message ( sd.name -- n )
\ it reuses the same code for the same message
dup 0= if nip exit then
code-by-message? if exit then exception
;
: throw-message ( sd.name -- ) obtain-code-by-message throw ;

\ testing

t{ [: "#error-test" throw-message ;] catch
message-by-code? -rot "#error-test" compare -> -1 0 }t

"#error-test" throw-message
\ the system should print "#error-test" as an error message.

By the definition of "exception" in Gforth I see that it isn't allowed
to be performed during compilation. But it can be corrected.

--
Ruvim

Re: Existing ior practice

<srh4ja$39d$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16254&group=comp.lang.forth#16254

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ruvim.pi...@gmail.com (Ruvim)
Newsgroups: comp.lang.forth
Subject: Re: Existing ior practice
Date: Mon, 10 Jan 2022 14:16:56 +0300
Organization: A noiseless patient Spider
Lines: 104
Message-ID: <srh4ja$39d$1@dont-email.me>
References: <2022Jan7.125232@mips.complang.tuwien.ac.at>
<srajop$vmc$1@dont-email.me> <sram42$1kes$1@gioia.aioe.org>
<srbg47$v6g$1@dont-email.me> <srbip9$131d$1@gioia.aioe.org>
<srbku8$puh$1@dont-email.me> <2022Jan8.115507@mips.complang.tuwien.ac.at>
<srcrap$q96$1@dont-email.me> <2022Jan9.183919@mips.complang.tuwien.ac.at>
<srh1tg$h8s$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Mon, 10 Jan 2022 11:16:58 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="7f23104408f5b07f9378fe974542ad6e";
logging-data="3373"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/g3yBtZCpjwFoRWAxLGyj4"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.4.1
Cancel-Lock: sha1:rqQVYBDAe4PatVwt1jjvLL3Up/g=
In-Reply-To: <srh1tg$h8s$1@dont-email.me>
Content-Language: en-US
 by: Ruvim - Mon, 10 Jan 2022 11:16 UTC

On 2022-01-10 13:31, Ruvim wrote:
> On 2022-01-09 20:39, Anton Ertl wrote:
>> Ruvim <ruvim.pinka@gmail.com> writes:
>>> On 2022-01-08 13:55, Anton Ertl wrote:
>>>> I don't know what dxforth means, but there is such a difference: A
>>>> library that is provided independent of systems cannot know what throw
>>>> codes are used by the system, and so has to define throw codes outside
>>>> the -4095..0 range.  OTOH, a library that is provided by the system
>>>> implementor for a specific system can know which throw codes the
>>>> system uses and in that case the lowest collision risk is if the
>>>> library uses throw codes in the -4095..-1 range that are not used by
>>>> anything else in the system (nor any other system library).
>>>
>>>
>>> Does it mean that if some vendor includes some portable library into its
>>> system, it should also change the throw codes in this library to the
>>> -4095..-256 range?
>>
>> That would be ideal for eliminating collision risks, but the fact that
>> we are considering such measures points to a lack in the Forth
>> standard.
>
>
> Yes, this lack exists, of course. It is just not too critical at the
> moment.
>
>
>
>
>>>> As an example, the version of EXCEPTION in the compat library uses
>>>> numbers outside the -4095..-1 range, while the version of EXCEPTION
>>>> built into Gforth uses numbers inside that range.
>>>
>>> So a third-party library should not use the built-in EXCEPTION word when
>>> it runs in Gforth to avoid -4095..-1 range, should it?
>>
>> No, using the built-in exception is a good idea?  In your scenario the
>> third-party library gets the throw code from a system word instead of
>> defining it itself, and of course using that throw code is perfectly
>> safe.  It knows how to avoid collisions with Gforth's built-in throw
>> codes, and avoids collisions with user-defined throw codes by using
>> numbers in the -4095..-1 range.
>
>
> Then it's as if this third-party library becomes a part of the system.
>
> And what about a program? May it use the built-in "EXCEPTION"? If yes,
> then it formally violates the restriction on programs (albeit it's
> totally safe).
>
>
>
> Concerning the "EXCEPTION" word as an API. This word has two functions:
> reserve a throw code, and associate a textual message with this code.
>
> Probably in a basic API these functions should be disjointed. And a
> general method to retrieve a message by a throw code should be a part of
> this API too.
>
> Also, an interesting thing is a method to retrieve a throw number by a
> message. Having such a method, something similar to my "sthrow" can be
> defined.  The key idea is that you don't need to declare exceptions
> beforehand, but just use them on the fly.
>
>   \ message-by-code?  ( n -- sd.message true | n false )
>   \ code-by-message?  ( sd.message -- n true | sd.message false )
>
>   : obtain-code-by-message ( sd.name -- n )
>     \ it reuses the same code for the same message
>     dup 0= if nip exit then
>     code-by-message? if exit then exception
>   ;
>   : throw-message ( sd.name -- ) obtain-code-by-message throw ;
>
>   \ testing
>
>   t{ [: "#error-test" throw-message ;] catch
>     message-by-code? -rot "#error-test" compare -> -1 0 }t
>
>   "#error-test" throw-message
>   \ the system should print "#error-test" as an error message.
>
>
> By the definition of "exception" in Gforth I see that it isn't allowed
> to be performed during compilation. But it can be corrected.

This doesn't occur in the example above, but it can occur in general.

E.g., for performance, it could be better to resolve the message in
compile time. And it can be done via a recognizer:

throw-message:error-test

or

throw-message( #error-test )

Yes, it is similar to 'ABORT"'. But it doesn't accept a flag, and it
produces a unique throw code for each unique message.

--
Ruvim

How to avoid collisions of throw codes (was: Existing ior practice)

<srh6ut$ivk$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16255&group=comp.lang.forth#16255

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!paganini.bofh.team!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ruvim.pi...@gmail.com (Ruvim)
Newsgroups: comp.lang.forth
Subject: How to avoid collisions of throw codes (was: Existing ior practice)
Date: Mon, 10 Jan 2022 14:57:15 +0300
Organization: A noiseless patient Spider
Lines: 112
Message-ID: <srh6ut$ivk$1@dont-email.me>
References: <2022Jan7.125232@mips.complang.tuwien.ac.at>
<srajop$vmc$1@dont-email.me> <sram42$1kes$1@gioia.aioe.org>
<srbg47$v6g$1@dont-email.me> <2022Jan8.112141@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Mon, 10 Jan 2022 11:57:17 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="7f23104408f5b07f9378fe974542ad6e";
logging-data="19444"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+k49oJIaw7RZ9K3GeqE4z2"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.4.1
Cancel-Lock: sha1:JLsJ4iNwriHGSHELEgg+YkPW6c0=
In-Reply-To: <2022Jan8.112141@mips.complang.tuwien.ac.at>
Content-Language: en-US
 by: Ruvim - Mon, 10 Jan 2022 11:57 UTC

On 2022-01-08 13:21, Anton Ertl wrote:
> Ruvim <ruvim.pinka@gmail.com> writes:
>> On 2022-01-08 03:33, dxforth wrote:
>>> The idea of ANS and systems reserving negative numbers is that programs
>>> could use positive numbers without risk - no?
>>
>> Maybe it was intended, but:
>>
>> 1. The corresponding restriction on systems is not declared.
[...]
>> 2. This risk is very low (did anybody face its occurrence in practice?).
>
> I tend to avoid defining new throw codes, partly because standard
> Forth does not have a good way to do it. I Gforth I have such a way,
> but I have also defined few new throw codes in Gforth-specific programs. Maybe we don't need that that often
>
>> 3. If a program uses libraries, such a risk exists anyway.
> ...
>> As an option to solve the problem of conflicting error codes, a method
>> to reserve error codes for programs can be developed and standardized.
>
> Many years ago (in 1999 or earlier) I have proposed
>
> http://www.forth200x.org/exception.html
>
> This is a pre-Forth-200x proposal that I never bothered to propose for
> Forth200x.
>
>> Probably, since we don't have such a method yet, then the problem is not
>> so critical in practice too.
>
> Yes: Checking iForth, lxf, SwiftForth, and VFX, none of them has
> picked up EXCEPTION. This is probably because need for defining throw
> codes in libraries is rare, and I guess the low importance of
> libraries in Forth also plays a role. Anyway, if you want to write a
> library for Gforth, Gforth has had EXCEPTION since at least 1998.

A word like "EXCEPTION" solves the problem of collision only partially.

The throw codes that EXCEPTION provides can change from run to run and
from one system to another system. So these codes cannot play a role of
fixed error codes.

But sometimes a program/library have to define fixed error codes. Some
possible reasons for that as follows:

1. Fixed codes should be a part of an API (for example, they are passed
to a different process).

2. Fixed codes should be referred in an external resource (e.g. an
external file with error messages in different languages).

So, fixed codes are really needed sometimes. How this problem can be
solved? As it is well known, by introducing extra level of indirection
(https://w.wiki/4aD).

Every new unique throw code shall be obtained from the system only. No
other way can guarantee uniqueness (a global directory for all libraries
is not an option, I guess).

Also, a system should provide a convenient API to identify a set of
throw codes and a way to create a bijection between this set and a set
of user-defined error codes.

Conceptually, a program/library should be able to define the following
words for its internal use in a portable way:

my-throw ( x.err|0 -- )
my-err? ( n -- x.err true | n false )

\ testing:

0 value ior1
0 value ior2

t{ [: 123 my-throw ;] catch dup to ior1 my-err? -> 123 -1 }t

t{ [: 456 my-throw ;] catch dup to ior2 my-err? -> 456 -1 }t

t{ [: 123 throw ;] catch my-err? -> 123 0 }t

t{ [: 123 my-throw ;] catch -> ior1 }t

t{ [: ior1 throw ;] catch my-err? -> 123 -1 }t
t{ [: ior2 throw ;] catch my-err? -> 456 -1 }t

t{ [: c" #err-03" my-throw ;] catch
my-err? swap count s" #err-03" compare -> -1 0 }t

t{ ior1 my-err? -> 123 -1 }t

The API should guarantee that the actual throw codes (like in ior1 and
ior2) are unique in the running process, among all loaded libraries or
modules.

Also, this API should provide a way to bijectively associate an error
message and a throw code.

When such an API is provided, the programs/libraries may be softly
restricted to encourage them to always obtain/reserve throw codes form
the system.

--
Ruvim

Re: Existing ior practice

<srhgmt$1st7$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16257&group=comp.lang.forth#16257

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Existing ior practice
Date: Tue, 11 Jan 2022 01:43:40 +1100
Organization: Aioe.org NNTP Server
Message-ID: <srhgmt$1st7$1@gioia.aioe.org>
References: <2022Jan7.125232@mips.complang.tuwien.ac.at>
<srajop$vmc$1@dont-email.me> <sram42$1kes$1@gioia.aioe.org>
<srbg47$v6g$1@dont-email.me> <srbip9$131d$1@gioia.aioe.org>
<srbku8$puh$1@dont-email.me> <2022Jan8.115507@mips.complang.tuwien.ac.at>
<srcrap$q96$1@dont-email.me> <2022Jan9.183919@mips.complang.tuwien.ac.at>
<srh1tg$h8s$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="62375"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.4.1
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Mon, 10 Jan 2022 14:43 UTC

On 10/01/2022 21:31, Ruvim wrote:
> On 2022-01-09 20:39, Anton Ertl wrote:
>> Ruvim <ruvim.pinka@gmail.com> writes:
>>> On 2022-01-08 13:55, Anton Ertl wrote:
>>>> I don't know what dxforth means, but there is such a difference: A
>>>> library that is provided independent of systems cannot know what throw
>>>> codes are used by the system, and so has to define throw codes outside
>>>> the -4095..0 range. OTOH, a library that is provided by the system
>>>> implementor for a specific system can know which throw codes the
>>>> system uses and in that case the lowest collision risk is if the
>>>> library uses throw codes in the -4095..-1 range that are not used by
>>>> anything else in the system (nor any other system library).
>>>
>>>
>>> Does it mean that if some vendor includes some portable library into its
>>> system, it should also change the throw codes in this library to the
>>> -4095..-256 range?
>>
>> That would be ideal for eliminating collision risks, but the fact that
>> we are considering such measures points to a lack in the Forth
>> standard.

The application is in charge. Let it assign the codes.

\ library
0 value throw1
0 value throw2

\ throw strings if requ'd
s" throw 1" 2constant $throw1
s" throw 2" 2constant $throw2

\ application
1000 to throw1
1001 to throw2

.... catch case
throw1 of $throw1 endof
throw2 of $throw2 endof
?dup if throw then exit
endcase cr type abort

\ alternatively SwiftForth's ?ABORT
.... catch
throw1 over = $throw1 ?abort
throw2 over = $throw2 ?abort
throw

Re: Existing ior practice

<2022Jan11.193644@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16277&group=comp.lang.forth#16277

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: Existing ior practice
Date: Tue, 11 Jan 2022 18:36:44 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 69
Message-ID: <2022Jan11.193644@mips.complang.tuwien.ac.at>
References: <2022Jan7.125232@mips.complang.tuwien.ac.at> <srajop$vmc$1@dont-email.me> <sram42$1kes$1@gioia.aioe.org> <srbg47$v6g$1@dont-email.me> <srbip9$131d$1@gioia.aioe.org> <srbku8$puh$1@dont-email.me> <2022Jan8.115507@mips.complang.tuwien.ac.at> <srcrap$q96$1@dont-email.me> <2022Jan9.183919@mips.complang.tuwien.ac.at> <srh1tg$h8s$1@dont-email.me>
Injection-Info: reader02.eternal-september.org; posting-host="c3802496c3dd689cf610bf8d6b3b9d6f";
logging-data="17380"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1989m591wZ5TiX3HzFlfAY+"
Cancel-Lock: sha1:wGxaV9FGZV9WwCognM2IpCQyT1Y=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Tue, 11 Jan 2022 18:36 UTC

Ruvim <ruvim.pinka@gmail.com> writes:
>On 2022-01-09 20:39, Anton Ertl wrote:
>> Ruvim <ruvim.pinka@gmail.com> writes:
>>> On 2022-01-08 13:55, Anton Ertl wrote:
>>>> As an example, the version of EXCEPTION in the compat library uses
>>>> numbers outside the -4095..-1 range, while the version of EXCEPTION
>>>> built into Gforth uses numbers inside that range.
>>>
>>> So a third-party library should not use the built-in EXCEPTION word when
>>> it runs in Gforth to avoid -4095..-1 range, should it?
>>
>> No, using the built-in exception is a good idea? In your scenario the
>> third-party library gets the throw code from a system word instead of
>> defining it itself, and of course using that throw code is perfectly
>> safe. It knows how to avoid collisions with Gforth's built-in throw
>> codes, and avoids collisions with user-defined throw codes by using
>> numbers in the -4095..-1 range.
>
>
>Then it's as if this third-party library becomes a part of the system.

No, Gforth's EXCEPTION is part of the system. It passes out throw
codes (from the system range) that programs (including libraries,
including non-system libraries) can THROW and CATCH, just like they
can THROW and CATCH the throw codes defined in the standard.

>And what about a program? May it use the built-in "EXCEPTION"?

Certainly.

>If yes,
>then it formally violates the restriction on programs (albeit it's
>totally safe).

What makes you think so?

>Concerning the "EXCEPTION" word as an API. This word has two functions:
>reserve a throw code, and associate a textual message with this code.
>
>Probably in a basic API these functions should be disjointed.

Why? I see no reason why a program should create a throw code without
associated text message, and also no reason why a program should
associate a text with an arbitrary number.

>And a
>general method to retrieve a message by a throw code should be a part of
>this API too.

The system certainly has this functionality somewhere if it outputs
the text message in the system catch handler. I have not needed this
functionality in a program yet, though.

>Also, an interesting thing is a method to retrieve a throw number by a
>message. Having such a method, something similar to my "sthrow" can be
>defined. The key idea is that you don't need to declare exceptions
>beforehand, but just use them on the fly.

But then you cannot check for that throw code in a CATCH, or (if using
the same message produces the same throw code) you have to repeat the
whole message. In the first case, you can just as well use abort".
The second case is cumbersome to use, and complicates implementation.

- 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: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: How to avoid collisions of throw codes (was: Existing ior practice)

<2022Jan11.232146@mips.complang.tuwien.ac.at>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16278&group=comp.lang.forth#16278

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ant...@mips.complang.tuwien.ac.at (Anton Ertl)
Newsgroups: comp.lang.forth
Subject: Re: How to avoid collisions of throw codes (was: Existing ior practice)
Date: Tue, 11 Jan 2022 22:21:46 GMT
Organization: Institut fuer Computersprachen, Technische Universitaet Wien
Lines: 36
Message-ID: <2022Jan11.232146@mips.complang.tuwien.ac.at>
References: <2022Jan7.125232@mips.complang.tuwien.ac.at> <srajop$vmc$1@dont-email.me> <sram42$1kes$1@gioia.aioe.org> <srbg47$v6g$1@dont-email.me> <2022Jan8.112141@mips.complang.tuwien.ac.at> <srh6ut$ivk$1@dont-email.me>
Injection-Info: reader02.eternal-september.org; posting-host="c3802496c3dd689cf610bf8d6b3b9d6f";
logging-data="23250"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ddLTldgJL0ZlDikzAFE2Y"
Cancel-Lock: sha1:iGwJ3+LqZUxm9cbSwlbVWMAxTjI=
X-newsreader: xrn 10.00-beta-3
 by: Anton Ertl - Tue, 11 Jan 2022 22:21 UTC

Ruvim <ruvim.pinka@gmail.com> writes:
>A word like "EXCEPTION" solves the problem of collision only partially.
>
>The throw codes that EXCEPTION provides can change from run to run and
>from one system to another system.

Sure. The same is true of, e.g., xts. Not a problem.

>But sometimes a program/library have to define fixed error codes. Some
>possible reasons for that as follows:
>
>1. Fixed codes should be a part of an API (for example, they are passed
>to a different process).

But what does this have to do with THROW codes?

>2. Fixed codes should be referred in an external resource (e.g. an
>external file with error messages in different languages).

I find error messages in different languages of dubious value
(basically it means that the user then has trouble googling for his
problem), but in any case, if we want to go there, we would probably
use a gettext-like interface, and use that to deal with not just error
messages, but all other messages as well. An error-message-only
mechanism is probably not a good idea.

>Every new unique throw code shall be obtained from the system only.

That's the idea behind EXCEPTION.

- 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: http://www.forth200x.org/forth200x.html
EuroForth 2021: https://euro.theforth.net/2021

Re: Existing ior practice

<srlu9f$ha0$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16279&group=comp.lang.forth#16279

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ruvim.pi...@gmail.com (Ruvim)
Newsgroups: comp.lang.forth
Subject: Re: Existing ior practice
Date: Wed, 12 Jan 2022 09:59:59 +0300
Organization: A noiseless patient Spider
Lines: 56
Message-ID: <srlu9f$ha0$1@dont-email.me>
References: <2022Jan7.125232@mips.complang.tuwien.ac.at>
<srajop$vmc$1@dont-email.me> <sram42$1kes$1@gioia.aioe.org>
<srbg47$v6g$1@dont-email.me> <srbip9$131d$1@gioia.aioe.org>
<srbku8$puh$1@dont-email.me> <2022Jan8.115507@mips.complang.tuwien.ac.at>
<srcrap$q96$1@dont-email.me> <2022Jan9.183919@mips.complang.tuwien.ac.at>
<srh1tg$h8s$1@dont-email.me> <srhgmt$1st7$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 12 Jan 2022 06:59:59 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c0f1b253fcaec0f7674d2bab912400b5";
logging-data="17728"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19XbtyH8lr56cV67UbdYXPi"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.4.1
Cancel-Lock: sha1:d8RExGX+KDlJi1I5cA0H/ulZ+94=
In-Reply-To: <srhgmt$1st7$1@gioia.aioe.org>
Content-Language: en-US
 by: Ruvim - Wed, 12 Jan 2022 06:59 UTC

On 2022-01-10 17:43, dxforth wrote:
> On 10/01/2022 21:31, Ruvim wrote:
>> On 2022-01-09 20:39, Anton Ertl wrote:
>>> Ruvim <ruvim.pinka@gmail.com> writes:
>>>>
>>>> Does it mean that if some vendor includes some portable library into
>>>> its
>>>> system, it should also change the throw codes in this library to the
>>>> -4095..-256 range?
>>>
>>> That would be ideal for eliminating collision risks, but the fact that
>>> we are considering such measures points to a lack in the Forth
>>> standard.
>
> The application is in charge.  Let it assign the codes.
>
> \ library
> 0 value throw1
> 0 value throw2
>
> \ throw strings if requ'd
> s" throw 1" 2constant $throw1
> s" throw 2" 2constant $throw2
>
> \ application
> 1000 to throw1
> 1001 to throw2

Why is it better than if the library allocates throw codes in the
system? (I mean, if such a method is standardized). E.g.:

s" throw 1" exception constant throw1
s" throw 2" exception constant throw2

An advantage of this method is that an application don't need to bear
the burden of assigning throw codes for all the libraries that it uses.

> ... catch case
>   throw1 of $throw1 endof
>   throw2 of $throw2 endof
>   ?dup if throw then  exit
> endcase  cr type abort
>
> \ alternatively SwiftForth's ?ABORT
> ... catch
> throw1 over = $throw1 ?abort
> throw2 over = $throw2 ?abort
> throw

It's possible, of course. But is it an API that you really want to use?

How do you see an ideal solution for this problem?

--
Ruvim

Re: Existing ior practice

<srm0n4$1qv8$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16280&group=comp.lang.forth#16280

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Existing ior practice
Date: Wed, 12 Jan 2022 18:41:24 +1100
Organization: Aioe.org NNTP Server
Message-ID: <srm0n4$1qv8$1@gioia.aioe.org>
References: <2022Jan7.125232@mips.complang.tuwien.ac.at>
<srajop$vmc$1@dont-email.me> <sram42$1kes$1@gioia.aioe.org>
<srbg47$v6g$1@dont-email.me> <srbip9$131d$1@gioia.aioe.org>
<srbku8$puh$1@dont-email.me> <2022Jan8.115507@mips.complang.tuwien.ac.at>
<srcrap$q96$1@dont-email.me> <2022Jan9.183919@mips.complang.tuwien.ac.at>
<srh1tg$h8s$1@dont-email.me> <srhgmt$1st7$1@gioia.aioe.org>
<srlu9f$ha0$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Info: gioia.aioe.org; logging-data="60392"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.4.1
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Wed, 12 Jan 2022 07:41 UTC

On 12/01/2022 17:59, Ruvim wrote:
>
> Why is it better than if the library allocates throw codes in the
> system? (I mean, if such a method is standardized). E.g.:
>
> s" throw 1" exception constant throw1
> s" throw 2" exception constant throw2
>
> An advantage of this method is that an application don't need to bear
> the burden of assigning throw codes for all the libraries that it uses.
> ...
>
> It's possible, of course. But is it an API that you really want to use?
>
> How do you see an ideal solution for this problem?

I'm not sure it represents enough of a problem to the programmer to warrant
burdening the system. Besides which EXCEPTION takes from the system's pool
of codes. Doesn't that make the codes ANS assigned to applications redundant?
At the very least it's taking things in a different direction.
OTOH I think ?ABORT is neat and it's a factor of ABORT". It existed as a
headerless word in DX-Forth because I couldn't see additional use for it -
until now. Who would have guessed.

Re: Existing ior practice

<srmqkc$5m7$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16283&group=comp.lang.forth#16283

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ruvim.pi...@gmail.com (Ruvim)
Newsgroups: comp.lang.forth
Subject: Re: Existing ior practice
Date: Wed, 12 Jan 2022 18:03:41 +0300
Organization: A noiseless patient Spider
Lines: 75
Message-ID: <srmqkc$5m7$1@dont-email.me>
References: <2022Jan7.125232@mips.complang.tuwien.ac.at>
<srajop$vmc$1@dont-email.me> <sram42$1kes$1@gioia.aioe.org>
<srbg47$v6g$1@dont-email.me> <srbip9$131d$1@gioia.aioe.org>
<srbku8$puh$1@dont-email.me> <2022Jan8.115507@mips.complang.tuwien.ac.at>
<srcrap$q96$1@dont-email.me> <2022Jan9.183919@mips.complang.tuwien.ac.at>
<srh1tg$h8s$1@dont-email.me> <srhgmt$1st7$1@gioia.aioe.org>
<srlu9f$ha0$1@dont-email.me> <srm0n4$1qv8$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 12 Jan 2022 15:03:40 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c0f1b253fcaec0f7674d2bab912400b5";
logging-data="5831"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19inlTytIOQadwTFrQ8yl72"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
Cancel-Lock: sha1:ZTSTHXKe6GLlgLu3/+z3nDii6/Y=
In-Reply-To: <srm0n4$1qv8$1@gioia.aioe.org>
Content-Language: en-US
 by: Ruvim - Wed, 12 Jan 2022 15:03 UTC

On 2022-01-12 10:41, dxforth wrote:
> On 12/01/2022 17:59, Ruvim wrote:
>>
>> Why is it better than if the library allocates throw codes in the
>> system? (I mean, if such a method is standardized). E.g.:
>>
>>     s" throw 1" exception constant throw1
>>     s" throw 2" exception constant throw2
>>
>> An advantage of this method is that an application don't need to bear
>> the burden of assigning throw codes for all the libraries that it uses.
>> ...
>>
>> It's possible, of course. But is it an API that you really want to use?
>>
>> How do you see an ideal solution for this problem?
>
> I'm not sure it represents enough of a problem to the programmer to warrant
> burdening the system.  Besides which EXCEPTION takes from the system's pool
> of codes.

What namely burdening to the system do you mean?

Usually a system already has some mechanism to associate error messages
with throw codes, that EXCEPTION probably can utilize (well, an opposite
example is SP-Forth, where this mechanism is based on external files
with error messages, so it cannot be used by the EXCEPTION word).

> Doesn't that make the codes ANS assigned to applications redundant?

If a program will be restricted to obtain new throw codes from the
system only, and if ANS ever assigned any range of throw codes to
applications only, then yes, this assignment would become redundant.

But ANS didn't. As I shown, Forth-94 doesn't restrict a system to the
range -4095..0 (it only recommends to use this range, see 9.3.1).
Consequently, it was impossible to assign the complementary range to
applications _exclusively_.

In any way, a standardized EXCEPTION (or something alike) shall provide
throw codes outside of the range {-255...0}, and without any other
restrictions (for example, it should not be restricted by the range
{-4095...-256}). Probably, it would be even better to provide new throw
codes only outside of the range {-4095...0}.

> At the very least it's taking things in a different direction.

And what a problem?

> OTOH I think ?ABORT is neat and it's a factor of ABORT".  It existed as a
> headerless word in DX-Forth because I couldn't see additional use for it -
> until now.  Who would have guessed.

?ABORT ( flag c-addr u -- )

Yes, it's a useful factor. Probably, an unconditional variant is
slightly more efficient (but more verbose in use).

To provide a way to rethrow or handle such an exception, a system should
also provide something like ABORTION-REASON ( -- c-addr u )
A complement word could be SET-ABORTION-REASON ( c-addr u -- )

And then "?ABORT" can be defined as follows

: ?abort ( flag c-addr u -- )
rot if set-abortion-reason -2 throw then 2drop
;

--
Ruvim

Re: Existing ior practice

<srmv81$9oc$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16284&group=comp.lang.forth#16284

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ruvim.pi...@gmail.com (Ruvim)
Newsgroups: comp.lang.forth
Subject: Re: Existing ior practice
Date: Wed, 12 Jan 2022 19:22:24 +0300
Organization: A noiseless patient Spider
Lines: 139
Message-ID: <srmv81$9oc$1@dont-email.me>
References: <2022Jan7.125232@mips.complang.tuwien.ac.at>
<srajop$vmc$1@dont-email.me> <sram42$1kes$1@gioia.aioe.org>
<srbg47$v6g$1@dont-email.me> <srbip9$131d$1@gioia.aioe.org>
<srbku8$puh$1@dont-email.me> <2022Jan8.115507@mips.complang.tuwien.ac.at>
<srcrap$q96$1@dont-email.me> <2022Jan9.183919@mips.complang.tuwien.ac.at>
<srh1tg$h8s$1@dont-email.me> <2022Jan11.193644@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 12 Jan 2022 16:22:25 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c0f1b253fcaec0f7674d2bab912400b5";
logging-data="9996"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/tUVDaLuzKK3YXJM7bAR+J"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
Cancel-Lock: sha1:lR5DV8CUGyTcWowbCNLkhCEUxo4=
In-Reply-To: <2022Jan11.193644@mips.complang.tuwien.ac.at>
Content-Language: en-US
 by: Ruvim - Wed, 12 Jan 2022 16:22 UTC

On 2022-01-11 21:36, Anton Ertl wrote:
> Ruvim <ruvim.pinka@gmail.com> writes:
>> On 2022-01-09 20:39, Anton Ertl wrote:
>>> Ruvim <ruvim.pinka@gmail.com> writes:
>>>> On 2022-01-08 13:55, Anton Ertl wrote:
>>>>> As an example, the version of EXCEPTION in the compat library uses
>>>>> numbers outside the -4095..-1 range, while the version of EXCEPTION
>>>>> built into Gforth uses numbers inside that range.
>>>>
>>>> So a third-party library should not use the built-in EXCEPTION word when
>>>> it runs in Gforth to avoid -4095..-1 range, should it?
>>>
>>> No, using the built-in exception is a good idea? In your scenario the
>>> third-party library gets the throw code from a system word instead of
>>> defining it itself, and of course using that throw code is perfectly
>>> safe. It knows how to avoid collisions with Gforth's built-in throw
>>> codes, and avoids collisions with user-defined throw codes by using
>>> numbers in the -4095..-1 range.
>>
>>
>> Then it's as if this third-party library becomes a part of the system.
>
> No, Gforth's EXCEPTION is part of the system. It passes out throw
> codes (from the system range) that programs (including libraries,
> including non-system libraries) can THROW and CATCH, just like they
> can THROW and CATCH the throw codes defined in the standard.

Yes, it's clear.

The initial point was that according to the standard (the current
version), any library should be considered as either a part of a system,
or a part of a program.

And if a library defines a throw code in the range -4095..-1, this
library should be considered as a part of the system, even if it's a
third party library. Since otherwise it's a part of the program, and it
makes the program formally not compliant.

>> And what about a program? May it use the built-in "EXCEPTION"?
>
> Certainly.
>
>> If yes,
>> then it formally violates the restriction on programs (albeit it's
>> totally safe).
>
> What makes you think so?

"Programs shall not define values for use with THROW in the range
{-4095...-1}" (in the section 9.3.1, Forth-2012).

But via your "EXCEPTION", a program defines for use a throw code in this
range. Hence the program formally violates this restriction.

>> Concerning the "EXCEPTION" word as an API. This word has two functions:
>> reserve a throw code, and associate a textual message with this code.
>>
>> Probably in a basic API these functions should be disjointed.
>
> Why? I see no reason why a program should create a throw code without
> associated text message,

(Disclaimer: I don't insist, it's just an idea for discussion)

The catch-throw mechanism is a general control flow mechanism. And it
can be used not only for error handling.

If a user can always bypass creating such a message, e.g.:

: next-exc ( -- n ) 0. exception ;

then why do you need to force him to always provide a message?

> and also no reason why a program should
> associate a text with an arbitrary number.

Not with arbitrary numbers, but with defined (in some sense) throw codes
only.

>>
>> And a general method to retrieve a message by a throw code
>> should be a part of this API too.
>
> The system certainly has this functionality somewhere if it outputs
> the text message in the system catch handler. I have not needed this
> functionality in a program yet, though.

Such a method can be required by a user-defined text interpreter (as
well as a method to recovery internal states after an error, as it was
discussed in 2021).

>> Also, an interesting thing is a method to retrieve a throw number by a
>> message. Having such a method, something similar to my "sthrow" can be
>> defined. The key idea is that you don't need to declare exceptions
>> beforehand, but just use them on the fly.
>
> But then you cannot check for that throw code in a CATCH, or (if using
> the same message produces the same throw code) you have to repeat the
> whole message.

I use such a lazy method to generate exceptions when I don't need to
check throw codes, and they are not a part of an API (actually, it's
majority). Sometimes I need to check an actual message (or its
_pattern_), since in such cases the message also brings some semantics
information for internal use (i.e. it is not only a message for logs).

> In the first case, you can just as well use abort".

I do: my "sthrow" is a factor of 'abort"'

One problem with that is the same as with "errno" — the information can
be lost when you clean up the objects before rethrow the exception.

> The second case is cumbersome to use, and complicates implementation.

To avoid complication of an implementation, a lower level API to solve
the problem can be only provided.

For example, if you can iterate over all the defined pairs of a throw
code and its message, the operations to find a message by a code, and
find a code by a message have almost the same complexity.

--
Ruvim

Re: How to avoid collisions of throw codes (was: Existing ior practice)

<srn0n5$l1q$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16285&group=comp.lang.forth#16285

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!paganini.bofh.team!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ruvim.pi...@gmail.com (Ruvim)
Newsgroups: comp.lang.forth
Subject: Re: How to avoid collisions of throw codes (was: Existing ior
practice)
Date: Wed, 12 Jan 2022 19:47:32 +0300
Organization: A noiseless patient Spider
Lines: 58
Message-ID: <srn0n5$l1q$1@dont-email.me>
References: <2022Jan7.125232@mips.complang.tuwien.ac.at>
<srajop$vmc$1@dont-email.me> <sram42$1kes$1@gioia.aioe.org>
<srbg47$v6g$1@dont-email.me> <2022Jan8.112141@mips.complang.tuwien.ac.at>
<srh6ut$ivk$1@dont-email.me> <2022Jan11.232146@mips.complang.tuwien.ac.at>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 12 Jan 2022 16:47:33 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c0f1b253fcaec0f7674d2bab912400b5";
logging-data="21562"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/dE2KDw2eVbIzBFxFpmd9f"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
Cancel-Lock: sha1:3qxsdcpIHph39Y0AqjgAEiRekis=
In-Reply-To: <2022Jan11.232146@mips.complang.tuwien.ac.at>
Content-Language: en-US
 by: Ruvim - Wed, 12 Jan 2022 16:47 UTC

On 2022-01-12 01:21, Anton Ertl wrote:
> Ruvim <ruvim.pinka@gmail.com> writes:
>> A word like "EXCEPTION" solves the problem of collision only partially.
>>
>> The throw codes that EXCEPTION provides can change from run to run and
>>from one system to another system.
>
> Sure. The same is true of, e.g., xts. Not a problem.
>
>> But sometimes a program/library have to define fixed error codes. Some
>> possible reasons for that as follows:
>>
>> 1. Fixed codes should be a part of an API (for example, they are passed
>> to a different process).
>
> But what does this have to do with THROW codes?

Ideally, — nothing. But such use is allowed by the current standard. So
we should support a migration, I think.

>> 2. Fixed codes should be referred in an external resource (e.g. an
>> external file with error messages in different languages).
>
> I find error messages in different languages of dubious value
> (basically it means that the user then has trouble googling for his
> problem), but in any case, if we want to go there, we would probably
> use a gettext-like interface, and use that to deal with not just error
> messages, but all other messages as well. An error-message-only
> mechanism is probably not a good idea.

Agreed.

But if somebody already use throw numbers for that, it should have a
clear way how to migrate on "random" throw numbers.

>> Every new unique throw code shall be obtained from the system only.
>
> That's the idea behind EXCEPTION.

Yes, and I support the idea of EXCEPTION

I only want to have a way:

1. to get new throw code without explicit declaration beforehand. I
mean, to get the throw code right inside the definition, on the fly,
immediately before throw.

2. to associate bijectively any number with new throw code.

Actually, the latter point can be implemented by a library in a portable
way.

--
Ruvim

Re: How to avoid collisions of throw codes (was: Existing ior practice)

<srn6ua$5bo$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16286&group=comp.lang.forth#16286

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ruvim.pi...@gmail.com (Ruvim)
Newsgroups: comp.lang.forth
Subject: Re: How to avoid collisions of throw codes (was: Existing ior
practice)
Date: Wed, 12 Jan 2022 21:33:45 +0300
Organization: A noiseless patient Spider
Lines: 28
Message-ID: <srn6ua$5bo$1@dont-email.me>
References: <2022Jan7.125232@mips.complang.tuwien.ac.at>
<srajop$vmc$1@dont-email.me> <sram42$1kes$1@gioia.aioe.org>
<srbg47$v6g$1@dont-email.me> <2022Jan8.112141@mips.complang.tuwien.ac.at>
<srh6ut$ivk$1@dont-email.me> <2022Jan11.232146@mips.complang.tuwien.ac.at>
<srn0n5$l1q$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Wed, 12 Jan 2022 18:33:46 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="c0f1b253fcaec0f7674d2bab912400b5";
logging-data="5496"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18MsTasKmCrFfrBAfimvfWz"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
Cancel-Lock: sha1:mgmn8YP7KLLM3tMvAomN3DFJrL0=
In-Reply-To: <srn0n5$l1q$1@dont-email.me>
Content-Language: en-US
 by: Ruvim - Wed, 12 Jan 2022 18:33 UTC

On 2022-01-12 19:47, Ruvim wrote:

>>> 2. Fixed codes should be referred in an external resource (e.g. an
>>> external file with error messages in different languages).
>>
>> I find error messages in different languages of dubious value
>> (basically it means that the user then has trouble googling for his
>> problem), but in any case, if we want to go there, we would probably
>> use a gettext-like interface, and use that to deal with not just error
>> messages, but all other messages as well.  An error-message-only
>> mechanism is probably not a good idea.
>
> Agreed.

As it appears, gettext is not a good choice.
See: https://github.com/projectfluent/fluent/wiki/Fluent-vs-gettext

> But if somebody already use throw numbers for that, it should have a
> clear way how to migrate on "random" throw numbers.

Fixed identifiers are essential. Probably, textual hierarchical
identifiers is a better choice in many cases.

--
Ruvim

Re: Existing ior practice

<srnsat$1erc$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16287&group=comp.lang.forth#16287

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Existing ior practice
Date: Thu, 13 Jan 2022 11:38:55 +1100
Organization: Aioe.org NNTP Server
Message-ID: <srnsat$1erc$1@gioia.aioe.org>
References: <2022Jan7.125232@mips.complang.tuwien.ac.at>
<srajop$vmc$1@dont-email.me> <sram42$1kes$1@gioia.aioe.org>
<srbg47$v6g$1@dont-email.me> <srbip9$131d$1@gioia.aioe.org>
<srbku8$puh$1@dont-email.me> <2022Jan8.115507@mips.complang.tuwien.ac.at>
<srcrap$q96$1@dont-email.me> <2022Jan9.183919@mips.complang.tuwien.ac.at>
<srh1tg$h8s$1@dont-email.me> <srhgmt$1st7$1@gioia.aioe.org>
<srlu9f$ha0$1@dont-email.me> <srm0n4$1qv8$1@gioia.aioe.org>
<srmqkc$5m7$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="47980"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.4.1
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Thu, 13 Jan 2022 00:38 UTC

On 13/01/2022 02:03, Ruvim wrote:
> On 2022-01-12 10:41, dxforth wrote:
>> On 12/01/2022 17:59, Ruvim wrote:
>>> ...
>>> How do you see an ideal solution for this problem?
>>
>> I'm not sure it represents enough of a problem to the programmer to warrant
>> burdening the system.  Besides which EXCEPTION takes from the system's pool
>> of codes.
>
> What namely burdening to the system do you mean?
>
> Usually a system already has some mechanism to associate error messages
> with throw codes, that EXCEPTION probably can utilize (well, an opposite
> example is SP-Forth, where this mechanism is based on external files
> with error messages, so it cannot be used by the EXCEPTION word).

Small systems may well find it a burden. Mine uses exactly two ANS
exceptions (codes -1 and -2) which I find sufficient. Implementing
EXCEPTION would likely require a linked list (or two as I have a split
dictionary). MARKER/FORGET would need to be involved to trim the lists
along with the dictionary. That's a lot of effort/resources to expend
for the privilege of having the system hand out codes.

> ...
>
>> OTOH I think ?ABORT is neat and it's a factor of ABORT".  It existed as a
>> headerless word in DX-Forth because I couldn't see additional use for it -
>> until now.  Who would have guessed.
>
> ?ABORT ( flag c-addr u -- )
>
> Yes, it's a useful factor. Probably, an unconditional variant is
> slightly more efficient (but more verbose in use).
>
> To provide a way to rethrow or handle such an exception, a system should
> also provide something like ABORTION-REASON ( -- c-addr u )
> A complement word could be SET-ABORTION-REASON ( c-addr u -- )
>
> And then "?ABORT" can be defined as follows
>
> : ?abort ( flag c-addr u -- )
> rot if set-abortion-reason -2 throw then 2drop
> ;

Yes. It's near identical to how I implemented it.

: ?ABORT ( n c-addr u -- ) rot if errmsg 2! -2 throw then 2drop ;

: (abort") ( n -- ) r> count 2dup + >r ?abort ;

: ABORT" state @ if postpone (abort") ," exit then
postpone s" ?abort ; immediate

Re: Existing ior practice

<srp2u5$8fu$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16288&group=comp.lang.forth#16288

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ruvim.pi...@gmail.com (Ruvim)
Newsgroups: comp.lang.forth
Subject: Re: Existing ior practice
Date: Thu, 13 Jan 2022 14:37:39 +0300
Organization: A noiseless patient Spider
Lines: 118
Message-ID: <srp2u5$8fu$1@dont-email.me>
References: <2022Jan7.125232@mips.complang.tuwien.ac.at>
<srajop$vmc$1@dont-email.me> <sram42$1kes$1@gioia.aioe.org>
<srbg47$v6g$1@dont-email.me> <srbip9$131d$1@gioia.aioe.org>
<srbku8$puh$1@dont-email.me> <2022Jan8.115507@mips.complang.tuwien.ac.at>
<srcrap$q96$1@dont-email.me> <2022Jan9.183919@mips.complang.tuwien.ac.at>
<srh1tg$h8s$1@dont-email.me> <srhgmt$1st7$1@gioia.aioe.org>
<srlu9f$ha0$1@dont-email.me> <srm0n4$1qv8$1@gioia.aioe.org>
<srmqkc$5m7$1@dont-email.me> <srnsat$1erc$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Thu, 13 Jan 2022 11:37:41 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="4630dafd484fc4202c8bb4e485bf4266";
logging-data="8702"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18XsbdzxI0kmIp/A9kbm+cY"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
Cancel-Lock: sha1:V8OlHJODOAwW244kCERuVSqe4jE=
In-Reply-To: <srnsat$1erc$1@gioia.aioe.org>
Content-Language: en-US
 by: Ruvim - Thu, 13 Jan 2022 11:37 UTC

On 2022-01-13 03:38, dxforth wrote:
> On 13/01/2022 02:03, Ruvim wrote:
>> On 2022-01-12 10:41, dxforth wrote:
>>> On 12/01/2022 17:59, Ruvim wrote:
>>>> ...
>>>> How do you see an ideal solution for this problem?
>>>
>>> I'm not sure it represents enough of a problem to the programmer to
>>> warrant
>>> burdening the system.  Besides which EXCEPTION takes from the
>>> system's pool
>>> of codes.
>>
>> What namely burdening to the system do you mean?
>>
>> Usually a system already has some mechanism to associate error messages
>> with throw codes, that EXCEPTION probably can utilize (well, an opposite
>> example is SP-Forth, where this mechanism is based on external files
>> with error messages, so it cannot be used by the EXCEPTION word).
>
> Small systems may well find it a burden.  Mine uses exactly two ANS
> exceptions (codes -1 and -2) which I find sufficient.  Implementing
> EXCEPTION would likely require a linked list (or two as I have a split
> dictionary).  MARKER/FORGET would need to be involved to trim the lists
> along with the dictionary.  That's a lot of effort/resources to expend
> for the privilege of having the system hand out codes.

A dedicated linked list is only one of possible implementations.
For example, a word list is a built in linked list that can be also
used. But it can implemented even without any linked list!

here constant magic-exception

: exception ( sd.message -- n )
align magic-exception , here >r ," r>
;
: message-by-throwcode? ( n -- c-addr u true | n false )
dup magic-exception here within 0= if false exit then
dup cell- @ magic-exception <> if false exit then
count true
;

In this simple variant we don't provide a method to find the throw code
by a message, and the "exception" word shall not be performed when the
current definition exists. But these limitations are not too difficult
to mitigate.

>> ...
>>
>>> OTOH I think ?ABORT is neat and it's a factor of ABORT".  It existed
>>> as a headerless word in DX-Forth because I couldn't see additional
>>> use for it - until now. Who would have guessed.
>>>
>>
>>     ?ABORT ( flag c-addr u -- )
>>
>> Yes, it's a useful factor. Probably, an unconditional variant is
>> slightly more efficient (but more verbose in use).
>>
>> To provide a way to rethrow or handle such an exception, a system should
>> also provide something like ABORTION-REASON ( -- c-addr u )
>> A complement word could be SET-ABORTION-REASON ( c-addr u -- )
>>
>> And then "?ABORT" can be defined as follows
>>
>>     : ?abort ( flag c-addr u -- )
>>       rot if set-abortion-reason -2 throw then 2drop
>>     ;
>
> Yes.  It's near identical to how I implemented it.
>
> : ?ABORT ( n c-addr u -- )  rot if  errmsg 2! -2 throw  then 2drop ;
>
> : (abort") ( n -- )  r> count 2dup + >r  ?abort ;
>
> : ABORT"  state @ if  postpone (abort")  ,"  exit  then
>   postpone s"  ?abort ; immediate

It shows a rare case when "postpone" is used in system-specific way to
later perform some interpretation semantics.

A less confusing way is to explicitly append execution semantics:
[ ' s" compile, ]
or perform it:
['] s" execute

These ways also works when the system provides a full compliant
"postpone" (i.e. without relying on RFI 99-027).

Also, the word '(abort")' is needless. Have a look:

: abort" ( flag "ccc" -- )
[ ' s" compile, ]
['] ?abort state @ if compile, else execute then
; immediate

Compilation or executing an xt depending on STATE I call "translation of
xt". It's a very useful factor:

: tt-xt ( i*x xt -- j*x )
state @ if compile, else execute then ;

Using this factor, definition for 'abort"' becomes even more compact:

: abort" ( flag "ccc" -- )
[ ' s" compile, ] ['] ?abort tt-xt ; immediate

(of course, it's still a system-dependent definition, since it relies on
specific implementation for 's"' ).

--
Ruvim

Re: Existing ior practice

<9c1d6ad1-f536-4b0c-a0e6-566190153351n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16291&group=comp.lang.forth#16291

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:ad4:4ea8:: with SMTP id ed8mr4528152qvb.52.1642087075296;
Thu, 13 Jan 2022 07:17:55 -0800 (PST)
X-Received: by 2002:a05:620a:1f2:: with SMTP id x18mr3522344qkn.99.1642087075100;
Thu, 13 Jan 2022 07:17:55 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Thu, 13 Jan 2022 07:17:54 -0800 (PST)
In-Reply-To: <srp2u5$8fu$1@dont-email.me>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:3f7a:20d0:2128:1645:d2a2:273d;
posting-account=V5nGoQoAAAC_P2U0qnxm2kC0s1jNJXJa
NNTP-Posting-Host: 2600:1700:3f7a:20d0:2128:1645:d2a2:273d
References: <2022Jan7.125232@mips.complang.tuwien.ac.at> <srajop$vmc$1@dont-email.me>
<sram42$1kes$1@gioia.aioe.org> <srbg47$v6g$1@dont-email.me>
<srbip9$131d$1@gioia.aioe.org> <srbku8$puh$1@dont-email.me>
<2022Jan8.115507@mips.complang.tuwien.ac.at> <srcrap$q96$1@dont-email.me>
<2022Jan9.183919@mips.complang.tuwien.ac.at> <srh1tg$h8s$1@dont-email.me>
<srhgmt$1st7$1@gioia.aioe.org> <srlu9f$ha0$1@dont-email.me>
<srm0n4$1qv8$1@gioia.aioe.org> <srmqkc$5m7$1@dont-email.me>
<srnsat$1erc$1@gioia.aioe.org> <srp2u5$8fu$1@dont-email.me>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <9c1d6ad1-f536-4b0c-a0e6-566190153351n@googlegroups.com>
Subject: Re: Existing ior practice
From: sdwjac...@gmail.com (S Jack)
Injection-Date: Thu, 13 Jan 2022 15:17:55 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 5
 by: S Jack - Thu, 13 Jan 2022 15:17 UTC

As a note I output error messages as well as prompt via errout. Clean data,
exclusive of messages and prompt, is output via stdout which can be directed
to a file or another display if so desired.
--
me

Re: Existing ior practice

<6d6ffa68-dcba-4ff2-957e-21bdd7c409d2n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16293&group=comp.lang.forth#16293

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:622a:506:: with SMTP id l6mr4352462qtx.61.1642093380709;
Thu, 13 Jan 2022 09:03:00 -0800 (PST)
X-Received: by 2002:ac8:5743:: with SMTP id 3mr4287988qtx.38.1642093380520;
Thu, 13 Jan 2022 09:03:00 -0800 (PST)
Path: i2pn2.org!i2pn.org!news.neodome.net!2.us.feeder.erje.net!feeder.erje.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Thu, 13 Jan 2022 09:03:00 -0800 (PST)
In-Reply-To: <9c1d6ad1-f536-4b0c-a0e6-566190153351n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:3f7a:20d0:b075:f017:d5ca:29d9;
posting-account=V5nGoQoAAAC_P2U0qnxm2kC0s1jNJXJa
NNTP-Posting-Host: 2600:1700:3f7a:20d0:b075:f017:d5ca:29d9
References: <2022Jan7.125232@mips.complang.tuwien.ac.at> <srajop$vmc$1@dont-email.me>
<sram42$1kes$1@gioia.aioe.org> <srbg47$v6g$1@dont-email.me>
<srbip9$131d$1@gioia.aioe.org> <srbku8$puh$1@dont-email.me>
<2022Jan8.115507@mips.complang.tuwien.ac.at> <srcrap$q96$1@dont-email.me>
<2022Jan9.183919@mips.complang.tuwien.ac.at> <srh1tg$h8s$1@dont-email.me>
<srhgmt$1st7$1@gioia.aioe.org> <srlu9f$ha0$1@dont-email.me>
<srm0n4$1qv8$1@gioia.aioe.org> <srmqkc$5m7$1@dont-email.me>
<srnsat$1erc$1@gioia.aioe.org> <srp2u5$8fu$1@dont-email.me> <9c1d6ad1-f536-4b0c-a0e6-566190153351n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <6d6ffa68-dcba-4ff2-957e-21bdd7c409d2n@googlegroups.com>
Subject: Re: Existing ior practice
From: sdwjac...@gmail.com (S Jack)
Injection-Date: Thu, 13 Jan 2022 17:03:00 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 8
 by: S Jack - Thu, 13 Jan 2022 17:03 UTC

Another note. In my exception handlers which end in an abort I use user abort, UABORT ,
a deferred word which is assigned a hard abort on startup. Hard abort resets the
vocabulary to Forth but many times I don't want that and I switch in a soft abort that
only resets data stack and quits. On some occasions I switch in behaviors that may
reset stack only and not quit, or noop and not do anything, or print stack and then quit,
etc.
--
me

Re: Existing ior practice

<793e31e0-33f0-4649-83ec-65165094c5f3n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16294&group=comp.lang.forth#16294

  copy link   Newsgroups: comp.lang.forth
X-Received: by 2002:a05:6214:624:: with SMTP id a4mr4791347qvx.127.1642093875597;
Thu, 13 Jan 2022 09:11:15 -0800 (PST)
X-Received: by 2002:ac8:6056:: with SMTP id k22mr1714628qtm.2.1642093873514;
Thu, 13 Jan 2022 09:11:13 -0800 (PST)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.forth
Date: Thu, 13 Jan 2022 09:11:13 -0800 (PST)
In-Reply-To: <9c1d6ad1-f536-4b0c-a0e6-566190153351n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=2600:1700:3f7a:20d0:b075:f017:d5ca:29d9;
posting-account=V5nGoQoAAAC_P2U0qnxm2kC0s1jNJXJa
NNTP-Posting-Host: 2600:1700:3f7a:20d0:b075:f017:d5ca:29d9
References: <2022Jan7.125232@mips.complang.tuwien.ac.at> <srajop$vmc$1@dont-email.me>
<sram42$1kes$1@gioia.aioe.org> <srbg47$v6g$1@dont-email.me>
<srbip9$131d$1@gioia.aioe.org> <srbku8$puh$1@dont-email.me>
<2022Jan8.115507@mips.complang.tuwien.ac.at> <srcrap$q96$1@dont-email.me>
<2022Jan9.183919@mips.complang.tuwien.ac.at> <srh1tg$h8s$1@dont-email.me>
<srhgmt$1st7$1@gioia.aioe.org> <srlu9f$ha0$1@dont-email.me>
<srm0n4$1qv8$1@gioia.aioe.org> <srmqkc$5m7$1@dont-email.me>
<srnsat$1erc$1@gioia.aioe.org> <srp2u5$8fu$1@dont-email.me> <9c1d6ad1-f536-4b0c-a0e6-566190153351n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <793e31e0-33f0-4649-83ec-65165094c5f3n@googlegroups.com>
Subject: Re: Existing ior practice
From: sdwjac...@gmail.com (S Jack)
Injection-Date: Thu, 13 Jan 2022 17:11:15 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 8
 by: S Jack - Thu, 13 Jan 2022 17:11 UTC

FigForth gets error text form block file when WARNING is set to one, otherwise it just
prints the error number. A system could just as easily get the text from a sequence
file.
I mark my block file with magic XYZZY which informs how the block file is configured
and if it has error text and where they are located. If the block file does not contain
error text, I set WARNING to zero.
--
me

Re: Existing ior practice

<srqeq7$grd$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16295&group=comp.lang.forth#16295

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Existing ior practice
Date: Fri, 14 Jan 2022 11:06:30 +1100
Organization: Aioe.org NNTP Server
Message-ID: <srqeq7$grd$1@gioia.aioe.org>
References: <2022Jan7.125232@mips.complang.tuwien.ac.at>
<srajop$vmc$1@dont-email.me> <sram42$1kes$1@gioia.aioe.org>
<srbg47$v6g$1@dont-email.me> <srbip9$131d$1@gioia.aioe.org>
<srbku8$puh$1@dont-email.me> <2022Jan8.115507@mips.complang.tuwien.ac.at>
<srcrap$q96$1@dont-email.me> <2022Jan9.183919@mips.complang.tuwien.ac.at>
<srh1tg$h8s$1@dont-email.me> <srhgmt$1st7$1@gioia.aioe.org>
<srlu9f$ha0$1@dont-email.me> <srm0n4$1qv8$1@gioia.aioe.org>
<srmqkc$5m7$1@dont-email.me> <srnsat$1erc$1@gioia.aioe.org>
<srp2u5$8fu$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="17261"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.4.1
Content-Language: en-GB
X-Notice: Filtered by postfilter v. 0.9.2
 by: dxforth - Fri, 14 Jan 2022 00:06 UTC

On 13/01/2022 22:37, Ruvim wrote:
>
> A dedicated linked list is only one of possible implementations.
> For example, a word list is a built in linked list that can be also
> used. But it can implemented even without any linked list!
>
> here constant magic-exception
>
> : exception ( sd.message -- n )
> align magic-exception , here >r ," r>
> ;
> : message-by-throwcode? ( n -- c-addr u true | n false )
> dup magic-exception here within 0= if false exit then
> dup cell- @ magic-exception <> if false exit then
> count true
> ;
>
> In this simple variant we don't provide a method to find the throw code
> by a message, and the "exception" word shall not be performed when the
> current definition exists. But these limitations are not too difficult
> to mitigate.

Interesting technique. Since n is an exception I would just throw it (e.g.
via ?ABORT). Personally I would have a hard time justifying EXCEPTION.
YMMV

>>
>> : ?ABORT ( n c-addr u -- )  rot if  errmsg 2! -2 throw  then 2drop ;
>>
>> : (abort") ( n -- )  r> count 2dup + >r  ?abort ;
>>
>> : ABORT"  state @ if  postpone (abort")  ,"  exit  then
>>   postpone s"  ?abort ; immediate
>
> It shows a rare case when "postpone" is used in system-specific way to
> later perform some interpretation semantics.
>
> A less confusing way is to explicitly append execution semantics:
> [ ' s" compile, ]
> or perform it:
> ['] s" execute
>
> These ways also works when the system provides a full compliant
> "postpone" (i.e. without relying on RFI 99-027).
>
>
> Also, the word '(abort")' is needless. Have a look:
>
> : abort" ( flag "ccc" -- )
> [ ' s" compile, ]
> ['] ?abort state @ if compile, else execute then
> ; immediate
>
>
> Compilation or executing an xt depending on STATE I call "translation of
> xt". It's a very useful factor:
>
> : tt-xt ( i*x xt -- j*x )
> state @ if compile, else execute then ;
>
> Using this factor, definition for 'abort"' becomes even more compact:
>
> : abort" ( flag "ccc" -- )
> [ ' s" compile, ] ['] ?abort tt-xt ; immediate
>
> (of course, it's still a system-dependent definition, since it relies on
> specific implementation for 's"' ).

For my DTC system, it was cheaper to compile (abort") than (s") ?abort.

Re: Existing ior practice

<srr591$dkg$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16296&group=comp.lang.forth#16296

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ruvim.pi...@gmail.com (Ruvim)
Newsgroups: comp.lang.forth
Subject: Re: Existing ior practice
Date: Fri, 14 Jan 2022 09:29:52 +0300
Organization: A noiseless patient Spider
Lines: 63
Message-ID: <srr591$dkg$1@dont-email.me>
References: <2022Jan7.125232@mips.complang.tuwien.ac.at>
<srajop$vmc$1@dont-email.me> <sram42$1kes$1@gioia.aioe.org>
<srbg47$v6g$1@dont-email.me> <srbip9$131d$1@gioia.aioe.org>
<srbku8$puh$1@dont-email.me> <2022Jan8.115507@mips.complang.tuwien.ac.at>
<srcrap$q96$1@dont-email.me> <2022Jan9.183919@mips.complang.tuwien.ac.at>
<srh1tg$h8s$1@dont-email.me> <srhgmt$1st7$1@gioia.aioe.org>
<srlu9f$ha0$1@dont-email.me> <srm0n4$1qv8$1@gioia.aioe.org>
<srmqkc$5m7$1@dont-email.me> <srnsat$1erc$1@gioia.aioe.org>
<srp2u5$8fu$1@dont-email.me> <srqeq7$grd$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Fri, 14 Jan 2022 06:29:53 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="411288a1ccf86be772bbae89f2196bea";
logging-data="13968"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/IsNPr4IjiJ5RjWwWsbIRQ"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
Cancel-Lock: sha1:+Pg1+0gT8oOeBD0OHEP/yWFRNBA=
In-Reply-To: <srqeq7$grd$1@gioia.aioe.org>
Content-Language: en-US
 by: Ruvim - Fri, 14 Jan 2022 06:29 UTC

On 2022-01-14 03:06, dxforth wrote:
> On 13/01/2022 22:37, Ruvim wrote:
>>
>> A dedicated linked list is only one of possible implementations.
>> For example, a word list is a built in linked list that can be also
>> used. But it can implemented even without any linked list!
>>
>>     here constant magic-exception
>>
>>     : exception ( sd.message -- n )
>>       align magic-exception , here >r ," r>
>>     ;
>>     : message-by-throwcode? ( n -- c-addr u true | n false )
>>       dup magic-exception here within 0= if false exit then
>>       dup cell- @ magic-exception <> if false exit then
>>       count true
>>     ;
>>
>> In this simple variant we don't provide a method to find the throw code
>> by a message, and the "exception" word shall not be performed when the
>> current definition exists. But these limitations are not too difficult
>> to mitigate.
>
> Interesting technique.  Since n is an exception I would just throw it (e.g.
> via ?ABORT).

Formally n is a throw code.

"?ABORT" doesn't accept a throw code, it accepts a flag and always uses
-2 as a throw code.

An arbitrary throw code can be used as the argument of THROW

s" test error message" exception constant my-ior
:noname my-ior throw ; catch message-by-throwcode? 0= abort" Err" type
\ it should print "test error message"

The system can use "message-by-throwcode?" to show an error message when
an exception was not caught by the user.

> Personally I would have a hard time justifying EXCEPTION. YMMV

I don't sure that namely this variant is worth standardizing. But I like
it's key idea, since it provides an easy way to avoid the possibility of
throw codes collision.

[...]
>> Using this factor, definition for 'abort"' becomes even more compact:
>>
>>     : abort" ( flag "ccc" -- )
>>       [ ' s" compile, ]  ['] ?abort tt-xt ; immediate
>>
>> (of course, it's still a system-dependent definition, since it relies on
>> specific implementation for 's"' ).
>
> For my DTC system, it was cheaper to compile (abort") than (s") ?abort.

Ah, I see. You save one cell per each use of 'abort"' in a definition.

--
Ruvim

Re: Existing ior practice

<srs1nj$13s0$1@gioia.aioe.org>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16297&group=comp.lang.forth#16297

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!aioe.org!7AktqsUqy5CCvnKa3S0Dkw.user.46.165.242.75.POSTED!not-for-mail
From: dxfo...@gmail.com (dxforth)
Newsgroups: comp.lang.forth
Subject: Re: Existing ior practice
Date: Sat, 15 Jan 2022 01:35:29 +1100
Organization: Aioe.org NNTP Server
Message-ID: <srs1nj$13s0$1@gioia.aioe.org>
References: <2022Jan7.125232@mips.complang.tuwien.ac.at>
<srajop$vmc$1@dont-email.me> <sram42$1kes$1@gioia.aioe.org>
<srbg47$v6g$1@dont-email.me> <srbip9$131d$1@gioia.aioe.org>
<srbku8$puh$1@dont-email.me> <2022Jan8.115507@mips.complang.tuwien.ac.at>
<srcrap$q96$1@dont-email.me> <2022Jan9.183919@mips.complang.tuwien.ac.at>
<srh1tg$h8s$1@dont-email.me> <srhgmt$1st7$1@gioia.aioe.org>
<srlu9f$ha0$1@dont-email.me> <srm0n4$1qv8$1@gioia.aioe.org>
<srmqkc$5m7$1@dont-email.me> <srnsat$1erc$1@gioia.aioe.org>
<srp2u5$8fu$1@dont-email.me> <srqeq7$grd$1@gioia.aioe.org>
<srr591$dkg$1@dont-email.me>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="36736"; posting-host="7AktqsUqy5CCvnKa3S0Dkw.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: en-GB
 by: dxforth - Fri, 14 Jan 2022 14:35 UTC

On 14/01/2022 17:29, Ruvim wrote:
> On 2022-01-14 03:06, dxforth wrote:
>> On 13/01/2022 22:37, Ruvim wrote:
>>>
>>> A dedicated linked list is only one of possible implementations.
>>> For example, a word list is a built in linked list that can be also
>>> used. But it can implemented even without any linked list!
>>>
>>>     here constant magic-exception
>>>
>>>     : exception ( sd.message -- n )
>>>       align magic-exception , here >r ," r>
>>>     ;
>>>     : message-by-throwcode? ( n -- c-addr u true | n false )
>>>       dup magic-exception here within 0= if false exit then
>>>       dup cell- @ magic-exception <> if false exit then
>>>       count true
>>>     ;
>>>
>>> In this simple variant we don't provide a method to find the throw code
>>> by a message, and the "exception" word shall not be performed when the
>>> current definition exists. But these limitations are not too difficult
>>> to mitigate.
>>
>> Interesting technique.  Since n is an exception I would just throw it (e.g.
>> via ?ABORT).
>
> Formally n is a throw code.
>
> "?ABORT" doesn't accept a throw code, it accepts a flag and always uses
> -2 as a throw code.
>
> An arbitrary throw code can be used as the argument of THROW
>
> s" test error message" exception constant my-ior
> :noname my-ior throw ; catch message-by-throwcode? 0= abort" Err" type
> \ it should print "test error message"
>
> The system can use "message-by-throwcode?" to show an error message when
> an exception was not caught by the user.
>
>
>> Personally I would have a hard time justifying EXCEPTION. YMMV
>
> I don't sure that namely this variant is worth standardizing. But I like
> it's key idea, since it provides an easy way to avoid the possibility of
> throw codes collision.

It's not worth standardizing message-by-throwcode? because most users will
say the system should be the error handler of last resort i.e. if I THROW
a code generated by EXCEPTION and don't CATCH it, the system should display
the message and abort.

Re: Existing ior practice

<srv1ul$e3b$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=16302&group=comp.lang.forth#16302

  copy link   Newsgroups: comp.lang.forth
Path: i2pn2.org!i2pn.org!eternal-september.org!reader02.eternal-september.org!.POSTED!not-for-mail
From: ruvim.pi...@gmail.com (Ruvim)
Newsgroups: comp.lang.forth
Subject: Re: Existing ior practice
Date: Sat, 15 Jan 2022 20:57:40 +0300
Organization: A noiseless patient Spider
Lines: 74
Message-ID: <srv1ul$e3b$1@dont-email.me>
References: <2022Jan7.125232@mips.complang.tuwien.ac.at>
<srajop$vmc$1@dont-email.me> <sram42$1kes$1@gioia.aioe.org>
<srbg47$v6g$1@dont-email.me> <srbip9$131d$1@gioia.aioe.org>
<srbku8$puh$1@dont-email.me> <2022Jan8.115507@mips.complang.tuwien.ac.at>
<srcrap$q96$1@dont-email.me> <2022Jan9.183919@mips.complang.tuwien.ac.at>
<srh1tg$h8s$1@dont-email.me> <srhgmt$1st7$1@gioia.aioe.org>
<srlu9f$ha0$1@dont-email.me> <srm0n4$1qv8$1@gioia.aioe.org>
<srmqkc$5m7$1@dont-email.me> <srnsat$1erc$1@gioia.aioe.org>
<srp2u5$8fu$1@dont-email.me> <srqeq7$grd$1@gioia.aioe.org>
<srr591$dkg$1@dont-email.me> <srs1nj$13s0$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Date: Sat, 15 Jan 2022 17:57:41 -0000 (UTC)
Injection-Info: reader02.eternal-september.org; posting-host="a1dc164c4e6ed9fd1170c18161b69930";
logging-data="14443"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+QWbyJN5cWIvkxBznpmIy/"
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101
Thunderbird/91.5.0
Cancel-Lock: sha1:P2e1VCkkETI51oGE6FnubF7KUTE=
In-Reply-To: <srs1nj$13s0$1@gioia.aioe.org>
Content-Language: en-US
 by: Ruvim - Sat, 15 Jan 2022 17:57 UTC

On 2022-01-14 17:35, dxforth wrote:
> On 14/01/2022 17:29, Ruvim wrote:
>> On 2022-01-14 03:06, dxforth wrote:
>>> On 13/01/2022 22:37, Ruvim wrote:
>>>>
>>>> A dedicated linked list is only one of possible implementations.
>>>> For example, a word list is a built in linked list that can be also
>>>> used. But it can implemented even without any linked list!
>>>>
>>>>     here constant magic-exception
>>>>
>>>>     : exception ( sd.message -- n )
>>>>       align magic-exception , here >r ," r>
>>>>     ;
>>>>     : message-by-throwcode? ( n -- c-addr u true | n false )
>>>>       dup magic-exception here within 0= if false exit then
>>>>       dup cell- @ magic-exception <> if false exit then
>>>>       count true
>>>>     ;
>>>>
>>>> In this simple variant we don't provide a method to find the throw code
>>>> by a message, and the "exception" word shall not be performed when the
>>>> current definition exists. But these limitations are not too difficult
>>>> to mitigate.
>>>
>>> Interesting technique.  Since n is an exception I would just throw it
>>> (e.g.
>>> via ?ABORT).
>>
>> Formally n is a throw code.
>>
>> "?ABORT" doesn't accept a throw code, it accepts a flag and always uses
>> -2 as a throw code.
>>
>> An arbitrary throw code can be used as the argument of THROW
>>
>>     s" test error message" exception constant my-ior
>>     :noname my-ior throw ; catch message-by-throwcode? 0= abort" Err"
>> type
>>     \ it should print "test error message"
>>
>> The system can use "message-by-throwcode?" to show an error message when
>> an exception was not caught by the user.
>>
>>
>>> Personally I would have a hard time justifying EXCEPTION. YMMV
>>
>> I don't sure that namely this variant is worth standardizing. But I like
>> it's key idea, since it provides an easy way to avoid the possibility of
>> throw codes collision.
>
> It's not worth standardizing message-by-throwcode? because most users will
> say the system should be the error handler of last resort i.e. if I THROW
> a code generated by EXCEPTION and don't CATCH it, the system should display
> the message and abort.

Yes, you are right, but it's unrelated to standardizing
"message-by-throwcode?". If no exception frame on the exception stack,
the system should display the message regardless of this word. And by
the section 9.6.1.2275 a system is already allowed to do it:

| Otherwise, the system may display an implementation-dependent
| message giving information about the condition associated
| with the THROW code n.

Also, I said nothing concerning standardizing the word
"message-by-throwcode?". But I believe such a word should be
standardized. It's useful to a user-defined text interpreter, to some
libraries for logging, etc. And such a function is usually implemented
by systems in any case.

--
Ruvim

Pages:123
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor