From: ruvim.pinka@gmail.com   
      
   On 2024-05-29 20:46, Anton Ertl wrote:   
   > Ruvim writes:   
   >> On 2024-05-24 15:56, Anton Ertl wrote:   
   >>> melahi_ahmed@yahoo.fr (Ahmed) writes:   
   >>>>   
   >>>> In Forth it is a bit messier because you   
   >>>> want a signature like   
   >>>>   
   >>>>   
   >>>> : d/dx ( xt -- xt ) .... ;   
   >>>   
   >>> Most probably he meant ( xt1 -- xt2 )   
   >>   
   >>   
   >>   
   >> Do you mean that ( xt -- xt ) is an incorrect stack diagram for this case?   
   >   
   > To me (and to vmgen) ( xt -- xt ) describes a word that expects an xt   
   > on the data stack but does not change the data stack at all.   
      
   Well, vmgen may introduce it's own stack notation.   
      
      
      
   > If two items in the stack effect comment have the same name (such as   
   > in this case), they have the same value. That's also the usage in the   
   > standard:   
   >   
   > | 6.1.1290 DUP dupe CORE   
   > | ( x -- x x )   
      
      
   But the diagram "( x -- 2*x )" is equivalent to it, isn't it?   
      
      
      
   [...]   
      
      
   >> I always thought that such use is correct. Because formally "xt"   
   >> (without an index) only denotes the data type, not a data value.   
   >   
   > Says who?   
      
   2.2.2 Stack notation says:   
      
   | /before/ represents the stack-parameter _data types_   
   | before execution of the definition and /after/ represents   
   | them after execution. The symbols used in /before/ and   
   | /after/ are shown in table 3.1.   
      
   The symbols in table 3.1 denote data types, not data objects (values).   
   In turn, a data type identifies a *set* of data objects.   
      
   Thus, a data type symbol in a stack diagram denotes a *set* of data   
   objects to which the corresponding stack-parameter belongs. (And this   
   correspondence is established by the position in the /before/ or /after/   
   tuple and in the stack).   
      
   Additional limitations on a stack-parameter can be *only* given in the   
   corresponding text description (which is defined in 2.2.4.2 Glossary   
   semantic description).   
      
   In a text description, a particular stack-parameter is referred by its   
   position on the stack, or by its corresponding element from the stack   
   diagram. Indices of stack diagram elements are only formally needed to   
   avoid ambiguity in such references. Any other meaning for indices is   
   only *informal*.   
      
      
   An example of referring stack parameters by position is the glossary   
   entry 6.2.2300 "TUCK":   
   | ( x1 x2 -- x2 x1 x2 )   
   | Copy the first (top) stack item below the second stack item.   
      
   NB: the requirement that the certain stack parameters are identical is   
   given in the text description.   
      
   The stack diagram ( 2*x -- 3*x ) is also formally correct for TUCK.   
   And the diagram ( x x -- x x x ) is equivalent to it.   
      
      
      
   So a rule of thumb for the /standard/ stack notation is this. If you   
   want to give an *informal* hint that some stack parameters are   
   identical, use the same indices (with the same data type symbols, of   
   course) for the corresponding elements of the stack diagram. If you want   
   to give an informal hint that some stack parameters (in the same data   
   type) *can* be not identical, use the different indices. Data type   
   symbols without indices don't give any hint.   
      
      
      
      
      
   [...]   
      
   >> For example "abs ( n -- +n )" — in some   
   >> cases the data values "before" and "after" are the same.   
   >   
   > The standard has:   
   >   
   > | ABS abs CORE   
   > | ( n -- u )   
   >   
   > So we don't know whether the standard considers "+n" to be the same   
   > name or a different name from "n".   
      
   Sure, we know. "+n" and "n" are symbols for different data types, and +n   
   is a sub-type of n. See 3.1.1 Data-type relationships   
      
    +n ⇒ n ⇒ x;   
    +n ⇒ u ⇒ x;   
      
      
   In my example I use "+n" rather then "u" as this is also correct for   
   "ABS", and puts more restrictions on the stack-parameter.   
      
      
   --   
   Ruvim   
      
   --- SoupGate-Win32 v1.05   
    * Origin: you cannot sedate... all the things you hate (1:229/2)   
|