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,047 of 117,927   
   albert@spenarnc.xs4all.nl to ruvim.pinka@gmail.com   
   Re: Back & Forth - Co-routines   
   02 Feb 25 12:13:54   
   
   In article , Ruvim   wrote:   
   >On 2025-01-31 11:33, dxf wrote:   
   >>   
   >> Not sure if previously mentioned but here's another version of LOCAL   
   >>   
   >> : ;:  >r ;   
   >>   
   >> : LOCAL ( x adr -- )   
   >>    r> -rot dup @ over 2>r ! ;: 2r> ! ;   
   >>   
   >> variable A  variable B  8 a !  7 b !   
   >>   
   >> : divide ( a b -- )  b local  a local   
   >>    a @  b @  /  . cr  ;   
   >>   
   >> 15 3 divide  a ? b ?   
   >>   
   >   
   >   
   >This approach does not work well with catch/throw. Because `throw` must   
   >restore the values of all "local" variables that are used in the   
   >definitions whose execution is being terminated. And this is difficult   
   >to implement.   
   >   
   >   
   >See also 13.3.3.1, item c,   
   >   
   >   
   >| ABORT shall release all local storage resources,   
   >| and CATCH / THROW (if implemented) shall release   
   >| such resources for all definitions whose execution   
   >| is being terminated.   
      
   Nice catch!   
      
   However, this is highly artificial. You have to have a recursive routine in   
   this   
   vein:   
      
   RECURSIVE   
   : fun .. fun ... fun . 'fun CATCH .. fun  ... ;   
      
   otherwise the global VARIABLE's can be ignored.   
      
   I would be interested to see a remotely plausible example of this.   
   Mixing recursion and exception is ill advised by iq<160.   
      
   Groetjes Albert   
      
      
   >   
   >   
   >--   
   >Ruvim   
   >   
   --   
   Temu exploits Christians: (Disclaimer, only 10 apostles)   
   Last Supper Acrylic Suncatcher - 15Cm Round Stained Glass- Style Wall   
   Art For Home, Office And Garden Decor - Perfect For Windows, Bars,   
   And Gifts For Friends Family And Colleagues.   
      
   --- 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