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 116,835 of 117,927   
   Ruvim to Anton Ertl   
   Re: value-flavoured structures   
   04 Oct 24 11:17:28   
   
   From: ruvim.pinka@gmail.com   
      
   On 2024-10-03 19:58, Anton Ertl wrote:   
   > Ruvim  writes:   
   >> On 2024-09-15 20:16, Anton Ertl wrote:   
   >>> A major merit for value-flavoured structures is that you can change   
   >>> the field size (e.g, from 1 byte to 2 bytes or vice versa) without   
   >>> changing all the code accessing those fields.  That's independent of   
   >>> cell size.   
   >>   
   >> Yes, you can change the field size, but only as far as its value   
   >> occupies the same number of a stack items and the stack is the same.   
   >   
   > Yes.  But you can switch between different sizes that all fit into a   
   > cell, or between different memory sizes of floats without changing the   
   > rest of the code.   
   >   
   >> Similar for the word `to` - `to` applies to the words created with   
   >> `value`, `fvalue`, `2value`. But the source code around `to foo` (and   
   >> `foo`) depends on the kind of `foo`, so the kind of `foo` cannot be   
   >> changed without changing the source code around where it is used.   
   >   
   > That's just as for reading the value-flavoured field; if a field   
   > pushes one cell, TO to the field also consumes one cell; likewise for   
   > float fields.   
      
      
   BTW, this is the same when the separate getter and setter (as ordinary   
   words) are used.  Both for value-flavoured variables and value-flavoured   
   structures.   
      
      
   ### Comparison of using a to-based setter ("to foo") and a separate   
   setter ("set-foo" for example) in source codes.   
      
   1. From the lexical point of view, "to foo" and "set-foo" are almost the   
   same.  "to foo" can even be considered a separate fancy word with a   
   space in its name.   
      
   2. "set-foo" has a separate entry in a word list, but "to foo" has no   
   its name token and execution token (in the general case [*]).   
   Some people consider the lack of a separate word as an advantage (as it   
   reduces the overall number of headers), but this says about resources   
   rather than using in source codes.   
      
   3. "set-foo" can be easily redefined (for example, if you want to check   
   the assigned value to prevent some bugs in advance).   
   "to foo" *cannot* be redefined. Although, one can redefine "to" to check   
   its argument and have a special action when its argument is "foo" — this   
   is very cumbersome.   
      
   4. "set-foo" can be accessed using qualified names, such as   
   mymodule::set-foo  or  mymodule( set-foo )   
   A variant like "to mymodule::foo" could work,   
   a variant like "to mymodule( set-foo )" cannot work.   
      
      
   Bottom line: I don't see any advantages in *using* a to-based setter   
   over a separate setter.   
      
      
      
   --   
   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