Path: ...!eternal-september.org!feeder3.eternal-september.org!news.eternal-september.org!eternal-september.org!.POSTED!not-for-mail From: anton@mips.complang.tuwien.ac.at (Anton Ertl) Newsgroups: comp.lang.forth Subject: Re: QUIT and ABORT Date: Sun, 04 May 2025 13:33:31 GMT Organization: Institut fuer Computersprachen, Technische Universitaet Wien Lines: 222 Message-ID: <2025May4.153331@mips.complang.tuwien.ac.at> References: <87bjtn2hct.fsf@gmail.com> <5ce2cb85311aa91fcb7ab57c802aef09b3345163@i2pn2.org> <2025May3.072517@mips.complang.tuwien.ac.at> <6973d7bc1d0376ab234a39a3dda82287b7b13450@i2pn2.org> <2025May3.180226@mips.complang.tuwien.ac.at> Injection-Date: Sun, 04 May 2025 17:14:09 +0200 (CEST) Injection-Info: dont-email.me; posting-host="d66a0ebe39fea8705e0ddcd39adb6200"; logging-data="2367147"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+u4MLDzsq0fEDrlT0636dp" Cancel-Lock: sha1:ppPO7CH/f9B8X2JmE561MYScmvY= X-newsreader: xrn 10.11 Bytes: 8278 dxf writes: >On 4/05/2025 2:02 am, Anton Ertl wrote: >> dxf writes: >>> Checking the doc it says: >>> >>> 9.3.5 Possible actions on an ambiguous condition >>> >>> A system choosing to execute THROW when detecting one of the ambiguous >>> conditions listed in table 9.3.6 shall use the throw code listed there. >> >> Calling ABORT or QUIT is not an ambiguous condition, so that section >> plays no role there. > >Yet ABORT ABORT" and QUIT are present in the table and assigned codes. For ABORT the section 9.6.2.0670 specifies that it performs a -1 THROW. While -1 happens to be the value shown in table 9.1 as being reserved for ABORT, there is no ambiguous condition involved here. Likewise for -2, ABORT" and section 9.6.2.0680. So table 9.1 is useful beyond the purpose of assigning throw codes to ambiguous conditions. However, for QUIT there is no redefinition in chapter 9. >It is clear to me all three are candidates for CATCHing and that this >was the intent. It may have been the intent of adding the -56 throw code to also have a corresponding redefinition of QUIT in Chapter 9, but they did not follow through on it. Maybe because -56 THROW changes the data stack depth while QUIT does not. >This is confirmed by the EXCEPTION EXT wordset in which >ABORT and ABORT" are required to be CATCHable irrespective of their >category. Category? A system that implements 9.6.2.0670 makes ABORT catchable, and a system that implements 9.6.2.0680 makes ABORT" catchable. I find it perverse that these words are in Exception ext, so you could have a system that has CATCH, but an uncatchable ABORT and/or an uncatchable ABORT". And for QUIT, the standard as it is does not have a catchable variant at all. >>> : QUIT -56 THROW ; >> >> That would not be a standard system, because in a standard system QUIT >> must do what 6.1.2050 QUIT says, and "-56 THROW" is not a correct >> implementation of that. > >No for the fact QUIT is CATCHable by virtue of its inclusion in the table >of codes in Section 9. There is nothing in the standard that makes such a connection (unlike for ABORT and ABORT"). I don't know for what purpose -56 was added to the table, but I know (and we have the proposal text) for what purpose -59 (ALLOCATE) was added to the table, and it was not with the intent of redefining ALLOCATE as : ALLOCATE -59 THROW ; So obviously it's just your interpretation of the table that if the description of a throw code C contains a word name W, systems implementing the exception wordset are free to redefine W as throwing C. >If OTOH you believe the inclusion of ABORT ABORT" >and QUIT was made in error then you have the option of testing that by >making a proposal to have them removed. The throw codes -1 and -2 were obviously added due to 9.6.2.0670 and 9.6.2.0680, not at all in error. I do not know why -56 was added, but it does not hurt, and existing programs might use it, so there is no good reason to remove it from the table. Admittedly, the presence in the table results in no guarantees from the standard, so removing the entry for -56 would not really hurt, either. In any case, such a proposal would only poll the opinion of the current committee, so it's not a way to find out whether the Forth-94 committee consider the addition of -56 to the table as a mistake. If someone made a proposal to the committee, existing practice would probably be considered more important than whatever we can still determine about the intent of the Forth-94 committee. I don't know a way to determine how many programs there are around that expect QUIT to be catchable, or that expect it not to be catchable, but for systems we can check relatively easily what they do: Here's the code I give to the Forth systems: 1 .( a ) cr -56 throw .( b ) ..s 2 .( a ) cr quit .( b ) ..s : foo 3 -56 throw ; ' foo catch 5 ..s : bar 4 quit ; ' bar catch 6 ..s Let's see what different Forth systems do: Gforth 0.7.9_20250409 1 .( a ) cr -56 throw .( b ) a *the terminal*:1:17: error: QUIT 1 .( a ) cr -56 >>>throw<<< .( b ) ..s <0> ok 2 .( a ) cr quit .( b ) a ..s <1> 2 ok 1 : foo 3 -56 throw ; ' foo catch 5 ok 3 ..s <3> 2 -56 5 ok 3 : bar 4 quit ; ' bar catch 6 ..s <4> 2 -56 5 4 ok 4 iForth 5.1-mini FORTH> 1 .( a ) cr -56 throw .( b ) a FORTH> .s Data: --- System: --- Float: --- ok FORTH> 2 .( a ) cr quit .( b ) a [1]FORTH> .s Data: 2 --- System: --- Float: --- ok [1]FORTH> : foo 3 -56 throw ; ' foo catch 5 [1]FORTH> .s Data: 2 --- System: --- Float: --- ok [1]FORTH> : bar 4 quit ; ' bar catch 6 [2]FORTH> .s Data: 2 4 --- System: --- Float: --- ok SwiftForth x64-Linux 4.0.0-RC89 15-Jul-2024 1 .( a ) cr -56 throw .( b ) a QUIT ..s <-Top ok 2 .( a ) cr quit .( b ) a ..s 2 <-Top ok : foo 3 -56 throw ; ' foo catch 5 ok ..s 2 -56 5 <-Top ok : bar 4 quit ; ' bar catch 6 .s 2 -56 5 4 <-Top ok VFX Forth 64 5.43 [build 0199] 2023-11-09 for Linux x64 1 .( a ) cr -56 throw .( b ) a No text available for THROW code -56(10) -> 1 .( a ) cr -56 throw .( b ) ^ ..s DATA STACK empty stack ok 2 .( a ) cr quit .( b ) a ..s DATA STACK top 2 0000:0000:0000:0002 ok-1 : foo 3 -56 throw ; ' foo catch 5 ok-3 ..s DATA STACK top 5 0000:0000:0000:0005 -56 FFFF:FFFF:FFFF:FFC8 2 0000:0000:0000:0002 ok-3 : bar 4 quit ; ' bar catch 6 ..s ========== REMAINDER OF ARTICLE TRUNCATED ==========