From: ruvim.pinka@gmail.com   
      
   On 2025-07-03 21:42, peter wrote:   
   > On Thu, 3 Jul 2025 20:47:07 +0400   
   > Ruvim wrote:   
      
   >> Yes, something like "private[ ... ]private" is a possible approach,   
   >> and its implementation seems simpler than adding the smarts to `:`   
   >> and `;` (and other defining words, if any).   
   >>   
   >> The advantage of this approach over "<: ... ;>" is that you can   
   >> define not only colon-definitions, but also constants, variables,   
   >> immediate words, one-time macros, etc.   
   >>   
   >>   
   >> : foo ( F: r.coefficient -- r.result )   
   >> private[   
   >> variable cnt   
   >> 0e fvalue k   
   >> : [x] ... ; immediate   
   >> ]private   
   >> to k 0 cnt !   
   >> ...   
   >> ;   
   >>   
   >> It's also possible to associated the word list of private words with   
   >> the containing word xt for debugging purposes.   
   >>   
   >>   
      
   >   
   > In lxf I have module, private, public, end-module   
   > your example would be   
   >   
   > module   
   > private   
   >   
   > variable cnt   
   > 0e fvalue k   
   > : [x] ... ; immediate   
   >   
   > public   
   >   
   > : foo ( F: r.coefficient -- r.result )   
   > to k 0 cnt !   
   > ...   
   > ;   
   >   
   > end-module   
      
   I usually take this approach too.   
   But in some cases it seems too wordy or long.   
      
   Usage of construct "<: ... ;>"   
      
   >   
   > end-module will remove all headers from the private words in the module   
      
      
   > I am not found of mixing definitions inside others.   
      
   By the way, local variables slightly break this principle. Also,   
   conceptually, a module definition contains definitions of other words   
   and possibly nested modules. And, conceptually, there is nothing wrong   
   with defining a module as a colon-definition.   
      
      
   --   
   Ruvim   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|