Forums before death by AOL, social media and spammers... "We can't have nice things"
|    comp.lang.forth    |    Forth programmers eat a lot of Bratwurst    |    117,927 messages    |
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
|    Message 117,301 of 117,927    |
|    dxf to Anton Ertl    |
|    Re: QUIT and ABORT    |
|    06 May 25 20:12:42    |
   
   From: dxforth@gmail.com   
      
   On 6/05/2025 5:13 pm, Anton Ertl wrote:   
   > dxf writes:   
   >> Except THROW special-cased codes -1 and -2 effectively reserving their   
   behaviour.   
   >> One can speculate why ANS didn't do so for -56 but to my mind QUIT when   
   implemented   
   >> should function as expected i.e. -56 THROW uncaught should perform QUIT.   
   >   
   > Currently the standard document does not agree with your mind, and   
   > therefore standard-compliant systems don't work the way you would   
   > like. You could try to write a proposal for what you have in mind.   
      
   Irrespective of the merits such a change to the spec for THROW would   
   be not be practical given most systems appear to use ANS' QUIT-based   
   exception handler. But for new implementers or the curious here is   
   how I organised mine and which is readily changeable.   
      
      
   \ return to OS with exit code   
   : RETURN ( code -- ) ... ;   
      
   \ perform ANS QUIT   
   : (quit) ( -- ) r0 @ rp! reset normal /interpret   
    begin cr (refill) drop interpret state? 0= if (vstat)   
    @execute then again ;   
      
   \ exit to OS or back to forth   
   : ?return ( code -- ) turnkey? if return then drop (quit) ;   
      
   \ clear data stacks   
   : (abort) ( i*x -- ) s0 @ sp! fs0 @ fsp ! 1 ?return ;   
      
   \ part of THROW   
   : error ( n -- )   
    -1 of (abort) then   
    -2 of boot cell+ @ 0= if .error then   
    space errmsg 2@ type (abort) then   
    ." THROW #" @base decimal swap . !base (abort) ;   
      
   : QUIT ( -- ) 0 ?return ; \ QUIT not trapped   
      
   \ QUIT is not trapped in DX-Forth but may be made so by   
   \ adding -56 of 1 ?return then to 'error' and defining   
   \ : QUIT -56 throw ;   
      
   : ?ABORT ( flag c-addr u -- )   
    rot if errmsg 2! -2 throw then 2drop ;   
      
   : (abort") ( flag -- ) r> count 2dup + >r ?abort ;   
      
   : ABORT" state @ if postpone (abort") ," end   
    postpone s" ?abort ; immediate   
      
   : ABORT -1 throw ;   
      
   --- SoupGate-DOS v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca