Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!wuarchive!mit-eddie!uw-beaver!ubc-cs!alberta!ncc!idacom!rob From: rob@idacom.uucp (Rob Chapman) Newsgroups: comp.lang.forth Subject: Re: Libraries for Forth Message-ID: <1990Aug30.193637.26428@idacom.uucp> Date: 30 Aug 90 19:36:37 GMT Organization: IDACOM, a division of Hewlett-Packard Lines: 69 > I really like your scheme. It does remind of the "vocabulary trees" in Thanks {;^{)-]--[ > > Applications are built in the modules while the tools reside in the libraries. > > > > When a library is opened, its words are inserted at the top of the Forth > > word list. This gives them priority in any naming conflicts. By opening > > libraries in the proper sequence, libraries are effectively stacked into > > the Forth wordlist. > > I'm a bit confused here. Are you saying that Modules are just libraries > with application code in them, or are they different from libraries? Sorry. What's lacking here is a definition of how we implement modules. The real difference is how and when words are added to libraries and modules. Libraries are like tool sets. An explicit effort must be made to add new words. The normal action is to OPEN and CLOSE them. ENCLOSE is used to add all the words defined since the library was OPENed. In modules, words are automatically added to the most recently entered module. The syntax was developed thru discussions with a MODULA-2 programmer: MODULE name ( declare a module and enter it ) define module words here EXPORT word ( move this word up into the parent module ) other exports END-MODULE ( exit the module ) Modules may be defined within modules for a hierarchial ordering. Its really an extension to figForth VOCABULARYs which allows the useful words to be exported for use while the inner workings of the module are encapsulated. Inside a MODULE, a library may be opened so that more words are available for the word definitions. Modules are used for information hiding and may be used within a library to hide the particular implementation. > > Around Forth-83, a second generation dictionary mechanism was proposed. > > This threw away the heirarchial dictionary tree provided by earlier efforts > > and replaced it with a dictionary stack. Definitions were added to the > > vocabulary which was on top of the stack and the whole stack was searched > > when looking up words. > > I'm not sure I see the difference. Are Forth-83 vocabularies conceptually > like your libraries? The similarity is the ability to specify the search order. A difference is that the programmer specifies whether words are enclosed by the most recently opened library or not. > The biggest difference I see is that in Forth-83 all > vocabulary names are global, where in your scheme you scoped library > names. Am I missing something else? The scoping is another difference. Programmers perspective is the most important difference. Libraries are available for reusing code while modules are provided for encapsulating within an application. > Thanks for making that posting. It looks like a nice clean system. > Have you been using it long? (BTW: Just curious, do you have any > idea as to the number of botForth users?). botForth is only about 1.5 years old but I've learned quite a lot about Forth and real-time since working with a much simpler system. I'm not in touch with any botForth users except for at work. Although, I have posted the kernel for the 68000 and the RTX2001A. Since the meta-compiler makes a good cross-compiler, a couple of hardware engineers ported it to the 6811 and the 8051 without to much trouble. Rob