• namespace collisions

    From Paul Rubin@no.email@nospam.invalid to comp.lang.forth on Sat Feb 1 16:29:43 2025
    From Newsgroup: comp.lang.forth

    In Haskell, if you import packages X and Y, and X contains a symbol
    "foo", you can refer to it as just "foo" or explicitly as X.foo.

    If both X and Y contain foo, then saying just "foo" is ambiguous and the compiler flags it as an error. You are required to say X.foo or Y.foo
    to indicate which one you want.

    Is there a simple way to do something like that in Forth, to get an
    error or at least a warning, if the same symbol occurs in multiple
    wordlists in the search order?

    Thanks.
    --- Synchronet 3.20c-Linux NewsLink 1.2
  • From anton@anton@mips.complang.tuwien.ac.at (Anton Ertl) to comp.lang.forth on Sun Feb 2 07:28:04 2025
    From Newsgroup: comp.lang.forth

    Paul Rubin <no.email@nospam.invalid> writes:
    If both X and Y contain foo, then saying just "foo" is ambiguous and the >compiler flags it as an error. You are required to say X.foo or Y.foo
    to indicate which one you want.

    Is there a simple way to do something like that in Forth, to get an
    error or at least a warning, if the same symbol occurs in multiple
    wordlists in the search order?

    If your Forth system supports recognizers, you can replace the name
    recognizer with one that searches the whole search order instead of
    stopping at the first match, and then prints a warning if there is
    more than one match, and returns the first match.

    Of course that only produces a warning if you actually access FOO
    (unlike what you specified), but I think it's the same for Haskell.

    - 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 2023 proceedings: http://www.euroforth.org/ef23/papers/
    EuroForth 2024 proceedings: http://www.euroforth.org/ef24/papers/
    --- Synchronet 3.20c-Linux NewsLink 1.2
  • From Paul Rubin@no.email@nospam.invalid to comp.lang.forth on Sun Feb 2 02:01:26 2025
    From Newsgroup: comp.lang.forth

    anton@mips.complang.tuwien.ac.at (Anton Ertl) writes:
    Of course that only produces a warning if you actually access FOO
    (unlike what you specified), but I think it's the same for Haskell.

    Yes, that is what is desired and it's what I thought I described.
    Thanks.
    --- Synchronet 3.20c-Linux NewsLink 1.2
  • From albert@albert@spenarnc.xs4all.nl to comp.lang.forth on Sun Feb 2 12:25:39 2025
    From Newsgroup: comp.lang.forth

    In article <87h65dxk7c.fsf@nightsong.com>,
    Paul Rubin <no.email@nospam.invalid> wrote:
    In Haskell, if you import packages X and Y, and X contains a symbol
    "foo", you can refer to it as just "foo" or explicitly as X.foo.

    If both X and Y contain foo, then saying just "foo" is ambiguous and the >compiler flags it as an error. You are required to say X.foo or Y.foo
    to indicate which one you want.


    Is there a simple way to do something like that in Forth, to get an
    error or at least a warning, if the same symbol occurs in multiple
    wordlists in the search order?

    No special measures are required.
    You look `fun up in the current search order, and say "isn't unique"
    You look `fun up in the all wordlists, and say "isn't globally unique".

    In ciforth you have an iterator for namespace (VOCABULARY's) e.g.
    \ Print all namespace (voc) names in existence.
    : .VOCS 'ID. FOR-VOCS ;

    Now replace the execution token ID. by a word using SEARCH-WORDLIST .

    You ask for something simple.
    That is neither here nor there.
    Use a simple Forth, then it is easy.
    If you use a difficult Forth, all tasks are difficult.


    Thanks.

    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.
    --- Synchronet 3.20c-Linux NewsLink 1.2