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 116,644 of 117,927    |
|    albert@spenarnc.xs4all.nl to dxforth@gmail.com    |
|    Re: recursion    |
|    17 Jul 24 12:17:54    |
   
   In article <66977721$1@news.ausics.net>, dxf wrote:   
   >On 16/07/2024 10:02 pm, sjack wrote:   
   >> Anton Ertl wrote:   
   >>> forward foo   
   >>>   
   >>> : bar ( n -- ) dup . 1- foo ;   
   >>>   
   >>> : foo ( n -- ) dup 0> if bar else drop then ;   
   >>>   
   >>> 5 foo \ prints "5 4 3 2 1 "   
   >>>   
   >>   
   >>   
   >> Toad code using Wil Baden type local macros ( /MM: MM ):   
   >>   
   >> "dup . 1- myself" /mm: bar OK   
   >>   
   >> : foo dup 0> if mm bar else drop then ; OK   
   >>   
   >> 5 foo 5 4 3 2 1 OK   
   >>   
   >> Note: The macro BAR does not remain in the system image.   
   >   
   >I would use:   
   >   
   > defer foo   
   >   
   > : bar ( n -- ) dup . 1- foo ;   
   >   
   > :noname ( n -- ) dup 0> if bar else drop then ; is foo   
   >   
   > 5 foo \ prints "5 4 3 2 1 "   
   >   
   >DEFER may not be as fast as a directly patched definition but neither   
   >has that prevented a generation from using it.   
   >   
      
   I applaud a sensible solution with standard words.   
      
   Groetjes Albert   
   --   
   Don't praise the day before the evening. One swallow doesn't make spring.   
   You must not say "hey" before you have crossed the bridge. Don't sell the   
   hide of the bear until you shot it. Better one bird in the hand than ten in   
   the air. First gain is a cat purring. - the Wise from Antrim -   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|
[   << oldest   |   < older   |   list   |   newer >   |   newest >>   ]
(c) 1994, bbs@darkrealms.ca