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,951 messages   

[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]

   Message 117,055 of 117,951   
   albert@spenarnc.xs4all.nl to ruvim.pinka@gmail.com   
   Re: Back & Forth - Co-routines   
   03 Feb 25 13:19:15   
   
   In article ,   
   Ruvim   wrote:   
   >On 2025-02-02 15:13, albert@spenarnc.xs4all.nl wrote:   
   >   
   >   
   >Recursion is not necessary. It is enough to use the same-name "local"   
   >variables in different functions, some of which throw exceptions, and   
   >other catch exceptions.   
   >   
   >An artificial example:   
   >   
   >   
   >: local ( x2 addr1 -- ; R: nest-sys1 -- x1 addr1 nest-sys.xt nest-sys1 )   
   >   \ This definition assumes that nest-sys size is 1 cell,   
   >   \ and xt is a subtype of nest-sys   
   >   r>  ( x2 addr nest-sys1 )   
   >   over dup @ >r >r  [: 2r> ! ;] >r   
   >   ( x2 addr1  nest-sys1 ) >r  !   
   >;   
   >   
   >   
   >: idiv ( n1 n2\0 -- n3  |  n1 0 -- never )   
   >   dup if / exit then -10 throw   
   >;   
   >   
   >variable a   
   >variable b   
   >   
   >: foo ( n1 n2 -- )   
   >   b local  a local   
   >   a @  b @  idiv   
   >   ."  idiv result is " . cr   
   >;   
   >: bar ( u1 -- u1 )   
   >   a local   
   >   100  a @  ['] foo catch if 2drop then   
   >   a @   
   >;   
   >   
   >0 bar .   
   >\ this must print 0, but will print 10   
   >   
      
   You share the same global storage for local's in different   
   words.   
   Try this with naming the local in bar `` c ''.   
      
   I maintain that if you are not in a recursive call for   
   a function with locals, and you try to catch the same function   
   call, everything is fine.   
   The challenge I posed remains, find a realistic scenarion that   
   leads to problems.   
      
   Groetjes Albrt   
      
   >--   
   >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