Sujet : Re: named wordlist
De : ruvim.pinka (at) *nospam* gmail.com (Ruvim)
Groupes : comp.lang.forthDate : 01. Nov 2024, 13:39:14
Autres entêtes
Organisation : A noiseless patient Spider
Message-ID : <vg2i5i$33mjv$1@dont-email.me>
References : 1 2 3
User-Agent : Mozilla Thunderbird
On 2024-10-30 20:47, Ruvim wrote:
On 2024-10-30 16:59, albert@spenarnc.xs4all.nl wrote:
In article <vfslvv$20cbt$1@dont-email.me>,
Ruvim <ruvim.pinka@gmail.com> 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: <https://forth-standard.org/proposals/vocabulary?hideDiff#reply-453>
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] <
https://forth-standard.org/proposals/new-words-latest-name-and-latest-name-in?hideDiff#reply-1251>
-- Ruvim