In article <
[email protected]>,
Marc Petremann <
[email protected]> wrote:
NEW ARTICLE
Explore vocabularies. It's a very powerful tool, but quite confusing for >anyone new to FORTH programming. >https://esp32.arduino-forth.com/article/elements_vocabularies
VOCABULARY don't exist formally. I took the opportunity to use
NAMESPACE to define wordlists that needs a name. ----------------------------------------------------
NAMESPACE
STACKEFFECT:
DESCRIPTION:
A defining word used in the form:
NAMESPACE cccc
to create a namespace definition cccc .
It will create a wordlist in the ISO sense. Subsequent use of cccc
will push this word list (the word list associated with cccc) to the
top of the search order in CONTEXT. So it will be searched first by
INTERPRET . A namespace 's data content field contains at first the
dovoc pointer (like for any DOES> word) , then follows its body. The
body contains the namespace ("vocabulary") link field address ( VLFA
). The VLFA points to the VLFA of the next namespace or a nil pointer
for the end. Then follows a dummy dea that serves as word list
identifier or WID in the sense of the ISO standard. It has empty
fields, except for the link field. The link field address contains the
DEA of the latest word of the namespace or a nil pointer if empty.
Executing the namespace means pushing its WID on top of the CONTEXT
order. In ciforth there can be at most 16 word list 's in the
search order, the oldest one gets lost. (ISO requires 8).
GLOSSARY INDEX
SEE ALSO: DEFINING VOC-LINK DEFINITIONS FOR-VOCS >WID
----------------------
It is not a synonym of VOCABULARY. It pushes the wordlist, not
replaces it. I consider that an anachronistic feature handed down
from the first implementations where there were two wordlists.
In ciforth all denotation words ( $ % # " ' 0-9 ) are real words 1]
and sit comfortably in a namespace called ONLY. Surprisingly
ONLY behaves conform ISO.
It is simple to add a facility PRIMES: on top of the namesspace
PRIME.
Then
PRIMES: PRIME? \ FORTH
is equivalent to
primes.prime() # python
Also
from math import * \ python
is equivalent to
MATH \ FORTH
(possibly followed by PREVIOUS).
Groetjes Albert
1] The prefix $ is executed when $1234 is encountered, etc.
--
Don't praise the day before the evening. One swallow doesn't make spring.
You must not say "hey" before you have crossed the bridge. Don't sell the
hide of the bear until you shot it. Better one bird in the hand than ten in
the air. First gain is a cat spinning. - the Wise from Antrim -
--- SoupGate-Win32 v1.05
* Origin: fsxNet Usenet Gateway (21:1/5)