• Vocabularies with ESP32forth

    From Marc Petremann@21:1/5 to All on Thu May 25 13:55:29 2023
    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

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From none) (albert@21:1/5 to mpetremann93m@gmail.com on Fri May 26 12:46:50 2023
    In article <5e230368-d434-43ad-9126-0f849cd64a3an@googlegroups.com>,
    Marc Petremann <mpetremann93m@gmail.com> 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)
  • From Zbig@21:1/5 to All on Fri May 26 07:43:24 2023
    But the „traditional” VOCABULARY word is nicer and better.
    We've got no namespaces in Forth, since the prefixes a
    namespace usually adds aren't in use in Forth.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From Marcel Hendrix@21:1/5 to none albert on Fri May 26 09:42:24 2023
    On Friday, May 26, 2023 at 12:49:10 PM UTC+2, none albert wrote:
    [..]
    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.
    [..]
    Then
    PRIMES: PRIME? \ FORTH

    Is this only for a single word, or should one pop back after PRIME?

    I remember one or two occasions where I want the same word for
    functions in different libraries/word-lists that both have to be present.

    -marcel

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From none) (albert@21:1/5 to zbigniew2011@gmail.com on Fri May 26 22:27:19 2023
    In article <0b80f20c-80ba-4840-93b9-1365047e350dn@googlegroups.com>,
    Zbig <zbigniew2011@gmail.com> wrote:
    But the „traditional” VOCABULARY word is nicer and better.
    We've got no namespaces in Forth, since the prefixes a
    namespace usually adds aren't in use in Forth.

    Don't fool yourself. Wordlists are the Forth equivalent of namespaces.

    Groetjes
    --
    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)
  • From none) (albert@21:1/5 to mhx@iae.nl on Fri May 26 22:37:24 2023
    In article <1fa99a36-fff2-4f54-a462-a9bbefe84dben@googlegroups.com>,
    Marcel Hendrix <mhx@iae.nl> wrote:
    On Friday, May 26, 2023 at 12:49:10 PM UTC+2, none albert wrote:
    [..]
    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.
    [..]
    Then
    PRIMES: PRIME? \ FORTH

    Is this only for a single word, or should one pop back after PRIME?

    I remember one or two occasions where I want the same word for
    functions in different libraries/word-lists that both have to be present.

    The idea is that it pops back.

    The other possibility is served by
    PRIMES \ not ALSO PRIMES
    initiate-primes
    17 prime?
    PREVIOUS

    The alternative is
    PRIMES PRIME? PREVIOUS
    is not too bad.

    But
    ALSO PRIMES PRIME? PREVIOUS
    is over the top, and bound to puzzle innocent bystanders.


    -marcel
    Groetjes Albert
    --
    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)
  • From Zbig@21:1/5 to All on Fri May 26 15:04:35 2023
    But the „traditional” VOCABULARY word is nicer and better.
    We've got no namespaces in Forth, since the prefixes a
    namespace usually adds aren't in use in Forth.
    Don't fool yourself. Wordlists are the Forth equivalent of namespaces.

    „Wordlists”, „namespaces”… it's better to stick with the traditional VOCABULARY
    in Forth. Which, besides, stresses it's not exactly the same as namespace.

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)
  • From none) (albert@21:1/5 to zbigniew2011@gmail.com on Sat May 27 12:40:41 2023
    In article <2aae137d-4cb7-41fa-91d9-063455f2fec8n@googlegroups.com>,
    Zbig <zbigniew2011@gmail.com> wrote:
    But the „traditional” VOCABULARY word is nicer and better.
    We've got no namespaces in Forth, since the prefixes a
    namespace usually adds aren't in use in Forth.
    Don't fool yourself. Wordlists are the Forth equivalent of namespaces.

    „Wordlists”, „namespaces”… it's better to stick with the traditional VOCABULARY
    in Forth. Which, besides, stresses it's not exactly the same as namespace.

    It is better to stick to the vocabulary (pun intended) used by the rest of
    the world, i.e. namespace.
    Which, besides, stresses that the name NAMESPACE is better because
    it is not the same as VOCABULARY.

    VOCABULARY is not in the standard because it is one of those archaic remnants.

    Groetjes Albert
    --
    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)
  • From Zbig@21:1/5 to All on Sat May 27 05:01:30 2023
    VOCABULARY is not in the standard because it is one of those archaic remnants.

    Not really „archaic”; VOCABULARY reminds us, that Forth was much
    more popular when it was featuring proper and accurate vocabulary. :)

    --- SoupGate-Win32 v1.05
    * Origin: fsxNet Usenet Gateway (21:1/5)