Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.forth > #42804

Re: namespace

Subject Re: namespace
References <n0934k$6kh$1@dont-email.me> <n09fqj$8pn$1@dont-email.me> <n0apph$3dl$1@dont-email.me> <n0be4i$o28$1@dont-email.me> <n0jket$d66$1@dont-email.me>
Newsgroups comp.lang.forth
From "Elizabeth D. Rather" <erather@forth.com>
Organization FORTH, Inc.
Date 2015-10-25 12:50 -1000
Message-ID <EOydnbJr_udQwbDLnZ2dnUU7-SOdnZ2d@supernews.com> (permalink)

Show all headers | View raw


On 10/25/15 12:20 PM, kristoff wrote:
> Hi all,
>
>
>
>
>
> On 22-10-15 21:43, rickman wrote:
>>> Is there a standard API in Forth for this kind of work, so that a Forth
>>> application on one microcontroller can be ported with limited (or no)
>>> effort?
>
>> Forth *is* the API.  If you mean are their standardized words for
>> talking to SPI, UART, I2C, etc, then I guess not.  But none of this is
>> hard to deal with in my opinion.
> (...)
>
> Well, I have a question about this.
>
> Today, I have been playing around a little bit with the code I have for
> setting the clock on the STM32F103. I ported the code I originally wrote
> to set the CPUspeed from assembler to Forth.
>
>
> If this would have been in (say) C or arduino (i.e. C++), what I would
> do now is drop the code somewhere on the internet (github), making it a
> seperate library/class.
> That way, the names of the functions I have written would surely not
> interfere with with somebody else might have used.
>
>
> How does one do this in Forth?
> Is there a way to set up different "namespaces". How do you make sure
> you can write code and that the names of the "functions" and "constants"
> do not get in eachother way.
>
> Or do you use names like "stm32f103_css.<something>" for all words and
> constants, just to make sure that they are all unique.
>
>
> I am still relative new to forth. I looked in the documentation I have
> for the concept of "namespaces" or something equivalent but did not find
> it. My appologies if I have overlooked it.

What you're looking for is "wordlists" or "vocabularies". They do 
provide a capability for specialized namespaces. There is a tendency for 
newbies to over-use them, though. My advice is to use them sparingly, 
for specialized code that supports a few high-level public words that 
use it. I always recommend studying the implementation of a 
well-regarded Forth system (ideally more than one) to see how 
experienced Forthers use these facilities.

Cheers,
Elizabeth

-- 
==================================================
Elizabeth D. Rather   (US & Canada)   800-55-FORTH
FORTH Inc.                         +1 310.999.6784
5959 West Century Blvd. Suite 700
Los Angeles, CA 90045
http://www.forth.com

"Forth-based products and Services for real-time
applications since 1973."
==================================================

Back to comp.lang.forth | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Forth and "embedded" enviroment kristoff <kristoff@skypro.be> - 2015-10-22 00:23 +0200
  Re: Forth and "embedded" enviroment Roberto Waltman <usenet@rwaltman.com> - 2015-10-21 19:19 -0400
  Re: Forth and "embedded" enviroment rickman <gnuarm@gmail.com> - 2015-10-21 21:59 -0400
    Re: Forth and "embedded" enviroment kristoff <kristoff@skypro.be> - 2015-10-22 15:37 +0200
      Re: Forth and "embedded" enviroment rickman <gnuarm@gmail.com> - 2015-10-22 15:43 -0400
        Re: Forth and "embedded" enviroment jonjo <jjonethal@yahoo.de> - 2015-10-22 15:26 -0700
          Re: Forth and "embedded" enviroment rickman <gnuarm@gmail.com> - 2015-10-23 03:20 -0400
        namespace (was: Forth and "embedded" enviroment) kristoff <kristoff@skypro.be> - 2015-10-25 23:20 +0100
          Re: namespace Paul Rubin <no.email@nospam.invalid> - 2015-10-25 15:45 -0700
            Re: namespace kristoff <kristoff@skypro.be> - 2015-10-25 23:53 +0100
              Re: namespace Paul Rubin <no.email@nospam.invalid> - 2015-10-25 16:18 -0700
                Re: namespace "Elizabeth D. Rather" <erather@forth.com> - 2015-10-25 14:01 -1000
                Re: namespace Paul Rubin <no.email@nospam.invalid> - 2015-10-25 17:40 -0700
          Re: namespace "Elizabeth D. Rather" <erather@forth.com> - 2015-10-25 12:50 -1000
            Re: namespace kristoff Bonne <kristoff@skypro.be> - 2015-10-26 00:11 +0100
              Re: namespace "Elizabeth D. Rather" <erather@forth.com> - 2015-10-25 14:10 -1000
                Re: namespace kristoff <kristoff@skypro.be> - 2015-11-03 23:11 +0100
                Re: namespace "Elizabeth D. Rather" <erather@forth.com> - 2015-11-03 16:17 -1000
                Re: namespace kristoff <kristoff@skypro.be> - 2015-11-07 17:56 +0100
          Re: namespace (was: Forth and "embedded" enviroment) hughaguilar96@gmail.com - 2015-10-25 16:31 -0700
          Re: namespace (was: Forth and "embedded" enviroment) anton@mips.complang.tuwien.ac.at (Anton Ertl) - 2015-10-26 11:23 +0000
        Re: Forth and "embedded" enviroment kristoff <kristoff@skypro.be> - 2015-11-03 12:16 +0100
          Re: Forth and "embedded" enviroment rickman <gnuarm@gmail.com> - 2015-11-03 11:12 -0500
            Re: Forth and "embedded" enviroment kristoff <kristoff@skypro.be> - 2015-11-04 14:06 +0100
              Re: Forth and "embedded" enviroment rickman <gnuarm@gmail.com> - 2015-11-04 09:29 -0500
  Re: Forth and "embedded" enviroment Matthias Koch <matthias.koch@hot.uni-hannover.de> - 2015-10-22 11:13 +0200
    Re: Forth and "embedded" enviroment kristoff <kristoff@skypro.be> - 2015-10-22 15:54 +0200
      Re: Forth and "embedded" enviroment Matthias Koch <matthias.koch@hot.uni-hannover.de> - 2015-10-22 16:42 +0200

csiph-web