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,056 of 117,927   
   albert@spenarnc.xs4all.nl to no.email@nospam.invalid   
   Re: Back & Forth - Co-routines   
   04 Feb 25 13:26:26   
   
   In article <874j1aycdt.fsf@nightsong.com>,   
   Paul Rubin   wrote:   
   >albert@spenarnc.xs4all.nl writes:   
   >> 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 thing about exceptions is that they occur unexpectedly.   
   Yeah right.   
      
   Think about it precisely.   
   You are in fun , recursively called from fun. A throw occurs in   
   this invocation but not from the external invocation.   
   You did not catch it in the external fun (otherwise all would be under   
   control). Can that cause problems by no restoring the variable?   
      
   >your recursive function prints something, and that works the first few   
   >times, but then the printer runs out of paper and there is an i/o   
   >exception.  It's not the recursive function's job to handle this.  The   
   >exception throws to some outer level handler that asks the user to fix   
   >the problem.   
      
   The printer runs out of paper during a recursive fibonacci call where you   
   print physically all the iteration stuff on a separate page.   
   You add new paper to the printer and you want to continue.   
   That is not a good example.   
   You call 100 'fib catch (don't mind the paper spill, but yes   
   the printer is guaranteed to run out of paper).   
   The problem is that you cannot recover! The catch makes no sense,   
   because the throw is made from in inner fib call.   
   Or do you can propose to adorn all recursive calls   
       : fib  ...   
           'fib catch ( enormous recovery for all cases including printer errors )   
           ...   
           'fib catch ( enormous recovery for all cases including printer errors )   
           ..   
       ;   
      
   >   
   >Adding (LOCAL) to a Forth interpreter should normally not be too   
   >difficulot, if you control the interpreter implementation.  It's the   
   >right way to do stuff like this.  Why mess around with all that awful   
   >stack juggling for a half-working and woefully slow solution?   
      
   That is not the point. We are discussing whether or not the   
   present solution is possible.   
   It is an academic discussion, because I don't use locals at all,   
   if they are absolutely necessary I use my enhanced `[ instead   
   of any style of locals   
      
   : root [ variable a variable b variable c ]   
     c ! b ! a !   
     \ now insert the famous quadratic root formula   
     [ hide a hide b hide c ]  \ Prevent "not unique messages"   
      
      
   Remark that is doesn't introduce any unfamiliar syntax,   
   only does away with "Forth shall not nested definitions"   
   (Says who?)   
   It is perfectly clear that this doesn't work where root   
   call itself recursively. But it doesn't call itself, so fine.   
      
   Groetjes Albert   
   --   
   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