Sujet : Re: QUIT and ABORT
De : ruvim.pinka (at) *nospam* gmail.com (Ruvim)
Groupes : comp.lang.forthDate : 05. May 2025, 18:29:19
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vvashh$ra84$1@dont-email.me>
References : 1 2 3 4 5 6 7 8 9 10 11 12
User-Agent : Mozilla Thunderbird
On 2025-05-05 08:11, dxf wrote:
On 4/05/2025 11:33 pm, Anton Ertl wrote:
...
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:
...
In DX-Forth QUIT is not CATCHable thus -56 THROW simply returns:
a
THROW #-56
However modifying it to do so gives these results:
1 .( a ) cr -56 throw .( b )
'a' is displayed and the stack is: 1
This violates the behavior of `throw` specified in 9.6.1.2275,
because if there is no a user's exception frame, the data stack must be emptied.
The table 9.1 in Forth-2012 (or 9.2 in Forth-94) does not affect the behavior of `throw` at all.
Your implementation will probably fail the following test case:
t{ 123 [: 999 -56 throw ;] catch 456 -> 123 -56 456 }t
2 .( a ) cr quit .( b )
'a' is displayed and the stack is: 2
: foo 3 -56 throw ; ' foo catch 5
stack is: -56 5
These cases are standard-compliant.
: bar 4 quit ; ' bar catch 6
stack is: -56 6
This violates `quit` 6.1.2050, because:
- `quit` is not allowed to remove anything from the data stack (in this case, remove 4 from the stack);
- `quit` is not allowed to place anything on the data stack (in this case, place `-56`);
- `quit` is not allowed to interpret the remaining part of the input buffer (in this case, interpret "6" and place 6 on the stack).
-- Ruvim