Path: utzoo!utgpu!news-server.csri.toronto.edu!rutgers!cs.utexas.edu!tut.cis.ohio-state.edu!pt.cs.cmu.edu!dsl.pitt.edu!pitt!willett!dwp From: dwp@willett.pgh.pa.us (Doug Philips) Newsgroups: comp.lang.forth Subject: Re: Postfixer FORTH Message-ID: <1560.UUL1.3#5129@willett.pgh.pa.us> Date: 20 Aug 90 01:42:11 GMT References: <9008180333.AA11956@ucbvax.Berkeley.EDU> Organization: String, Scotch tape, and Paperclips. (in Pgh, PA) Lines: 72 In <9008180333.AA11956@ucbvax.Berkeley.EDU>, DAVID@PENNDRLS.BITNET writes: > Actually my logic was as follows: Is is a word that takes a string and > builds an index entry that points to Here. Constant and : are 'defining > words' that lay down a Code Field and Body. Remember that the index is > not required for FORTH execution. The compiler looks up words in the > Index and compiles the address to which the index entry points. Like > data types in FORTH, it is the programmer's responsability to see to it > that Is was called only to label an address where he or she subsequently > put a Code Field. Is doesn't care, and neither does the compiler. Ok, I think I understand a bit better what you're trying to do. I think that you have removed the prefix nature of CREATE, because the name comes first. Unfortunately the binding for the name still comes after. There is an implicit parameter, HERE, which is what binds the name to the code that defines it. First, the implicit "HERE" parameter means that if the code which is defining the word contains immediate words that invoke Is, you're out of luck. I'm not quite sure if the use of global variables is or isn't a deciding factor for post-fix-ness. I would be inclined to say no, because *all* the parameters should be on the stack. This has the nice side-effect that the words are reentrant. > In > fact, if one were to define the system such that the index was located > in a different area than the dictionary, one could use Is to label an > arbitrary memory location, such as defining a label in an assembler > program: > > " 2Push" Is Code: BX Push, " 1Push" Is AX Push, > " Next" Is ..... ;Code Second, I think that the requirement for separate dictionary and code spaces is overly restrictive and unnecessary. As for the specifics of your labelled code example, a question: Does Is rip out the previous string from the definition, or is " an IMMEDIATE word in the assembler vocabulary (assuming you use vocabularies)? Aside from allowing arbitrary labelling of words in code, I'm don't get the advantage to using Is to label an arbitrary memory location. If Is binds its name to HERE, I don't see quite how the location could be truly arbitrary. If Is could define a truly arbitrary memory location, wouldn't that mean the location's address would have to be on the stack? Seems like that is a more cleanly post-fix solution. How about this example of a purely postfix version of CODE: ( vocabulary manipulations as necessary go here...) : CODE: ( -- cfa-able-address ) ... ; IMMEDIATE CODE: BX PUSH CODE: AX PUSH CODE: ( Machinations for NEXT... ) ;Code " Next" Is " 1Push" Is " 2Push" Is My claim is that if you have more stack-ed addresses than you can keep track of, you are doing something wrong. It maybe that with CODE: you are justified in performing arbitrary complex operations and that if normal Forth factoring were an issue you wouldn't be using CODE: in the first place. Of course, in my example, I assume that CODE: doesn't do anything obnoxious like create a code prolog or do any alignment, etc. Of course those restrictions would apply equally to your example. -Doug --- Preferred: ( dwp@willett.pgh.pa.us OR ...!{sei,pitt}!willett!dwp ) Daily: ...!{uunet,nfsun}!willett!dwp [last resort: dwp@vega.fac.cs.cmu.edu]