Liste des Groupes | Revenir à cl forth |
On 18/05/2025 6:16 pm, Ruvim wrote:[...]On 2025-05-18 06:58, dxf wrote:
I only said ANS made provision for it. It is for the implementer to decide[...]
whether it is useful to them and how to provide it.
Hence, `-56` is a special case in your implementation.I transfer control to (abort) except in the case of -56 where it passes to (quit).The actual code is here:>
>
https://pastebin.com/FAmufbki
An excerpt:
>
: error ( n -- ) \ part of THROW
-1 of (abort) then
-2 of boot cell+ @ 0= if .error then
space errmsg 2@ type (abort) then
-56 of 1 ?return then
." THROW #" @base decimal swap . !base (abort) ;
>
: THROW ( n -- )
?dup if catcher @ ?dup 0= if error then rp!
r> catcher ! 2r> fsp ! swap >r sp! drop r> then ;
>
: CATCH ( xt -- n | 0 )
sp@ fsp @ 2>r catcher @ >r rp@ catcher !
execute 0 r> catcher ! 2r> 2drop ;
>
End of excerpt.
>
Note that in `error` you don't transfer control to `(abort)` only in the case of `-56`.
If any of the following tests fail, then `evaluate` (or `throw`) is not compliant:The other differences are only related to the different error messagesINCLUDE uses CATCH , EVALUATE does not.
and can be factored out. For example, an equivalent definition:
>
: error ( S: n\0 -- never )
dup print-error
-56 = if 1 ?return ( S: never ) then
(abort) ( S: never )
;
>
>
>
Another question is how are `evaluate` and `included` implemented?
>
I assume they use `catch`.
Yes, it can be correct in the sense that it is in accordance with your system documentation. But it is not in accordance with the ANS Forth standard (as well as Forth-2012).Then your Forth system probably shows the following behavior in its terminal:The first case is correct behaviour for a system that implements a catchable QUIT.
>
999 -56 throw
ok 999 <
>
s" 999 -56 throw" evaluate
ok
>
Of course, the first case shows a non-standard behavior.
The result of the second case depends upon whether CATCH was involved.Yes, sure.
But moreover, the second case means that your catchable `quit` will not keep the data stack when it is called from `evaluate` or `included` (or `load`).It's what I expect from a catchable QUIT. ANS doesn't compel anyone to implement
>
And what is the use of this?
a catchable QUIT. Same as ANS didn't compel anyone to implement a catchable ABORT
or ABORT". But if you choose to make them catchable, you wear the result.
Les messages affichés proviennent d'usenet.