Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!purdue!decwrl!labrea!Portia!jessica.stanford.edu!duggie From: duggie@jessica.stanford.edu (Doug Felt) Newsgroups: comp.lang.forth Subject: Questions about scoping Keywords: scope, memory, names Message-ID: <3547@Portia.Stanford.EDU> Date: 2 Sep 88 17:38:09 GMT Sender: news@Portia.Stanford.EDU Reply-To: duggie@jessica.stanford.edu (Doug Felt) Organization: Stanford University Lines: 57 Some questions for those more up on these things than me: Back in 1984 I used Forth to write a large graphics adventure-type educational program for the Apple II. I had special needs (accomodating third-party graphics routines, and squeezing everything into 48K) so wrote my own Forth and editor so I could dispose of the headers, do I/O in the way I needed, generate subroutine-threaded (jsr addr, jsr addr...) code, and so on. I say this so that people will believe me :-) when I say that I like Forth and appreciate its many strengths. I have not used Forth much since then, although I have used Mach(I) on the Mac to play around with. Usually I use C or Object Pascal these days. I read stuff in MacTutor but don't know what current Forth development systems provide, or what public-domain utilities there might be. I would like to know if there are ways around the following problems I have had with Forth systems I have seen: 1) I would like to use something like header files in C, which I can include so as to avoid typing in lots of constant definitions for offsets into structures, parameters, and so on, all of which can be very error-prone. At the same time I would not like to compile hundreds of constants into my code, 99% of which will never be used. Stuff I see in MacTutor usually has pages of constants for just this purpose. Lots of effort compared to including a few header files. 2) Are there any good ways to scope names and other declarations? Again I am thinking of static functions in C and and statics global to all the routines in a file. The Forth I wrote in '84 let me put names in either of two places, one of which was thrown away after the 'module' was compiled and the private names were no longer needed. This way I didn't need to worry about what these names were when I used this dictionary later-- only the 'exported' names were there. I find name collisions a real headache. Other types of scoping like nested functions, constants local to a function, names of parts of structures, etc also fall into this category. 3) Are there good mechanisms for dynamic memory management? I'm thinking of heaps, linked lists, trees, and so on. I found it difficult to use such structures in straight Forth because I couldn't easily grow and shrink them-- since code and data went into the same chunk of memory, and the only other dynamic data area was the stack. I have to use the host machine's operating system to get the memory to do anything like this, which tends to tie me pretty closely to the machine (of course, on the Mac this is a given anyway). Am I seriously off base here? Have these issues been addressed and solved long ago? Is there some secret cache of wonderful Forth tools sitting out in netland waiting for me to stumble upon it, so that I may rediscover the True Word (tick, perhaps, or comma?) ;-) Thanks for everyone's patience! Doug Felt Courseware Authoring Tools Project Sweet Hall 3rd Floor Stanford University duggie@jessica.stanford.edu