Discussion:
named wordlist
(too old to reply)
Ruvim
2024-10-30 07:07:41 UTC
Permalink
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)?


--
Ruvim
a***@spenarnc.xs4all.nl
2024-10-30 12:59:56 UTC
Permalink
Post by Ruvim
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.
Every sane Forth uses VOCABULARY , or in my case NAMESPACE
because I didn't want to make a choice.
[If you load a program and you get the definition of VOCABULARY
incompatible, and you don't notice it, this means a hard to find
bug]

So every sane Forth normally displays the names of namespaces,
(and not the handles you get form GET-ORDER,)
however they are defined via VOCABULARY or NAMESPACE.

However:
Supposed I abuse the data structure wordlist in a lisp implementation.
They are used with SEARCH-WORDLIST and some such, but if they
happens to be present in the search order, it make no sense to
hunt for a name associated with it.

A typical situation is
WORDLIST CONSTANT my-lisp-whatever

Are you going to inspect all constants?
or worse

_ _ class lisp
M: lisp-words ALSO @ CONTEXT ! M; ( wordlist id commaed in ) ,
M: .... M; .
M: whatever ... M;

endclass

Usage :
17 wordlist lisp my-lisp
Post by Ruvim
--
Ruvim
Groetjes Albert
--
Temu exploits Christians: (Disclaimer, only 10 apostles)
Last Supper Acrylic Suncatcher - 15Cm Round Stained Glass- Style Wall
Art For Home, Office And Garden Decor - Perfect For Windows, Bars,
And Gifts For Friends Family And Colleagues.
Ruvim
2024-10-30 16:47:39 UTC
Permalink
Post by a***@spenarnc.xs4all.nl
Post by Ruvim
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"




--
Ruvim
Ruvim
2024-11-01 12:39:14 UTC
Permalink
Post by Ruvim
Post by a***@spenarnc.xs4all.nl
Post by Ruvim
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>
  : 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
Anton Ertl
2024-10-30 18:38:57 UTC
Permalink
Post by Ruvim
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?
Gforth 0.7.9_20241016
...
wordlist constant foo ok
foo >order ok
order foo Forth Forth Root Forth ok
wordlist ok 1
variable bla ok 1
constant bar ok
bar >order ok
order <139623990855032> foo Forth Forth Root Forth ok

I.e., Gforth supports the usage

wordlist constant foo

in ORDER, but not the general case.
Post by Ruvim
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.
All standard Forth systems support CONSTANT. Or what do you mean with
"associate a name with a word list"?

- anton
--
M. Anton Ertl http://www.complang.tuwien.ac.at/anton/home.html
comp.lang.forth FAQs: http://www.complang.tuwien.ac.at/forth/faq/toc.html
New standard: https://forth-standard.org/
EuroForth 2024: https://euro.theforth.net
Ruvim
2024-10-30 20:37:40 UTC
Permalink
Post by Anton Ertl
Post by Ruvim
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?
Gforth 0.7.9_20241016
...
wordlist constant foo ok
foo >order ok
order foo Forth Forth Root Forth ok
wordlist ok 1
variable bla ok 1
constant bar ok
bar >order ok
order <139623990855032> foo Forth Forth Root Forth ok
I.e., Gforth supports the usage
wordlist constant foo
in ORDER, but not the general case.
Anyway, that's cool!
Post by Anton Ertl
Post by Ruvim
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.
All standard Forth systems support CONSTANT. Or what do you mean with
"associate a name with a word list"?
Probably, "name" is not an appropriate term.

I mean, associate a character string with a wid so that `order` displays
this string for that wid when outputting the search order.


--
Ruvim
a***@spenarnc.xs4all.nl
2024-11-01 12:57:35 UTC
Permalink
Post by Ruvim
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.
ORDER SEE LOCATE .S are introspective words.
They are inseparable from the Forth they belong too.
Neither of these words has an output that you can build on to generate
other words.
So they are "best effort" words, they can be high quality if present
in an elaborate system like gforth, or they can be missed at all.
In ciforth you can recompile the result of SEE , while other Forth's
priority is to give insight of e.g. optimisation.
Post by Ruvim
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?
In view of the above, I consider philosophizing about how to further
define the above words futile.

<SNIP>
Post by Ruvim
--
Ruvim
Groetje Albert
--
Temu exploits Christians: (Disclaimer, only 10 apostles)
Last Supper Acrylic Suncatcher - 15Cm Round Stained Glass- Style Wall
Art For Home, Office And Garden Decor - Perfect For Windows, Bars,
And Gifts For Friends Family And Colleagues.
Loading...