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,383 of 117,927   
   Ruvim to Anton Ertl   
   Re: Nested definitions   
   02 Jul 25 20:58:17   
   
   From: ruvim.pinka@gmail.com   
      
   On 2025-07-02 19:12, Anton Ertl wrote:   
   > Ruvim  writes:   
   >> On 2025-07-02 15:37, albert@spenarnc.xs4all.nl wrote:   
   >>> Or it has not even know it, if [ is smart enough to compile a jump to   
   >>> after ].   
   >>   
   >> This can be tricky because the following should work:   
   >>   
   >>    create foo [ 123 , ] [ 456 ,   
   >>   
   >>    : bar  [ ' foo compile, 123 lit, ] ;   
   >   
   > Or something.  Anyway, [ and ] are used for a variety of purposes and   
   > trying to smarten them seems fraught with pitfalls.  If one really   
   > wants to have   
   >   
   > : foo ... [ : bar ... ; ] ... ;   
   >   
   > work, it may be better to put the smarts into : and ;.  E.g., on a   
   > system with sections, they could switch to another section and back.   
      
   Yes, and I wonder why introducing new words like `<:` and `;>` is better   
   than putting the smarts into `:` and `;`.   
      
      
   > The benefit of defining a normal colon definition inside another colon   
   > definition eludes me, however.  Maybe mutual recursion, but the need   
   > is rare and deferred words handle that well.   
      
   As I can see, the idea is that the name of a nested definition has the   
   limited scope — the same as a local variable, and it is not visible   
   outside of the containing definition.   
      
      
   So, the program like:   
      
      : foo   
        ...   
        [ : bar ... ; ]   
        ...   
        bar   
        ...   
      ;   
      
   Is equivalent to:   
      
      get-current wordlist push-order definitions   
      
        : bar ... ;   
      
      set-current   
        : foo   
          ...   
          bar   
          ...   
        ;   
      previous   
      
      
      
      
   --   
   Ruvim   
      
   --- 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