home bbs files messages ]

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,138 of 117,927   
   sjack to Ruvim   
   Re: Back & Forth - Co-routines   
   22 Mar 25 15:51:18   
   
   From: sjack@dontemail.me   
      
   Ruvim  wrote:   
      
   > An artificial example:   
      
   While wondering down roads less taken, I took a path where   
   bacForth CUT: and -CUT were used in lieu of CATCH THROW .   
      
      
   ( ENTER is the same as ';:' )   
   : LOCAL ( x adr -- )   
       r> -rot dup @ over 2>r ! ENTER 2r> ! ;   
      
   \ prefixed '-' to indicate this word does a cut   
   : -idiv ( n1 n2\0 -- n3 |  n1 0 -- true )   
     dup if /   
       else 2drop true -CUT   
       then   
      
      
   : ?idiv ( n1 n2 -- n1/n2 false |  )   
     CUT: -idiv ." Valid: " false   
      
      
   42 variable a   
   42 variable b   
      
   : ?/ ( u1 u2 -- u1/u2 )   
     a local b local   
     b @ a @ ?idiv   
     if ." Bogus! " 666 then .   
      
      
   i. 100 5 ?/ --> Valid: 20   
   i. a ? b ? --> 42 42   
   i. 100 0 ?/ --> Bogus! 666   
   i. a ? b ? --> 42 42   
      
   forget ?/   
      
   : ?/ ( u1 u2 -- u1/u2 )   
     a local b local   
     b @ a @ ' ?idiv ENTER   
     if ." Bogus! " 666 then .   
      
      
   i. 100 5 ?/ --> Valid: 20   
   i. a ? b ? --> 42 42   
   i. 100 0 ?/ --> Bogus! 666   
   i. a ? b ? --> 42 42   
      
   forget ?/   
      
   : ?/ ( u1 u2 -- u1/u2 )   
     a local b local   
     b @ a @ (: cut: -idiv ." Valid: " false ;) ENTER   
     if ." Bogus! " 666 then .   
      
      
   i. 100 5 ?/ --> Valid: 20   
   i. a ? b ? --> 42 42   
   i. 100 0 ?/ --> Bogus! 666   
   i. a ? b ? --> 42 42   
      
   +echo   
   -fin-   
      
   --- 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