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,920 of 117,927   
   Ruvim to Ruvim   
   Re: named wordlist   
   01 Nov 24 16:39:14   
   
   From: ruvim.pinka@gmail.com   
      
   On 2024-10-30 20:47, Ruvim wrote:   
   > On 2024-10-30 16:59, albert@spenarnc.xs4all.nl wrote:   
   >> In article ,   
   >> Ruvim   wrote:   
   >>> When a word list is created with `vocabulary`, it is associated with a   
   >>> name, and `order` displays this name in its output.   
   >>>   
   >>> When a word list is created by `wordlist`, it is not associated with a   
   >>> name. Therefore, `order` typically displays a number for that word list,   
   >>> which is less informative.   
   >>>   
   >>> A Forth system might try to find a constant whose value is identical to   
   >>> the wid of such word list and display the name of the constant. Do you   
   >>> know if this approach is used anywhere?   
   >>>   
   >>> Some Forth systems technically can associate a name with a word list   
   >>> after the word list is created with `wordlist`. And some even provide an   
   >>> API for doing so.   
   >>>   
   >>> Do you know of any Forth systems that technically *cannot* associate a   
   >>> name with a word list created with `wordlist` (due to internal details)?   
   >>   
   >> VOCABULARY didn't make it in the standard because conflicts.   
   >   
   > Because of what conflicts?   
   >   
   >   
   > BTW, the word `vocabulary` was standardized in 2020.   
   > See:    
   >   
   >   
   > It is possible to obtain the wid from a vocabulary:   
   >   
   >    : vocabulary>wordlist ( xt.vocabulary -- wid )   
   >      also execute   
   >      get-order swap >r 1- set-order r>   
   >    ;   
   >   
   >    ' forth vocabulary>wordlist forth-wordlist = .   
   >    \ this should print "-1"   
      
      
      
   We can even define a word `wordlist-labeled  ( sd.label -- wid )`   
   that creates a word list with a label.   
      
      
      : exch-current ( wid -- wid )   
        get-current swap set-current   
      ;   
      
      wordlist constant (labels-for-wordlists)   
      
      : wordlist-labeled ( sd.label -- wid )   
        (labels-for-wordlists) exch-current >r   
        ['] vocabulary execute-parsing   
        latest-name name>interpret ( xt.vocabulary )   
        vocabulary>wordlist ( wid )   
        r> exch-current drop   
      ;   
      
      \ test   
      "foo" wordlist-labeled ( wid )   
      \ NB:   
      latest-name name>string type   
      \ output: "wordlist-labeled"  (not "foo")   
      
      exch-current order   
      \ it outputs "foo" for the compilation word list   
      exch-current ( wid ) constant foo-wl   
      
      
   Note that even though `wordlist-labeled` creates a word in the internal   
   wordlist, this has no effect on the program that uses `wordlist-labeled`   
   in terms of `lastest-name` [1].   
      
      
      
   The question is whether it is possible to associate a label with an   
   existing word list (in a system-specific way, of course).   
      
      
      
      
   [1]   
      
      
   --   
   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