Path: utzoo!utgpu!news-server.csri.toronto.edu!mailrus!ukma!tut.cis.ohio-state.edu!ucbvax!PENNDRLS.BITNET!DAVID From: DAVID@PENNDRLS.BITNET Newsgroups: comp.lang.forth Subject: Postfixer FORTH Message-ID: <9008230629.AA29489@ucbvax.Berkeley.EDU> Date: 21 Aug 90 19:30:29 GMT Sender: daemon@ucbvax.BERKELEY.EDU Reply-To: DAVID%PENNDRLS.BITNET@SCFVM.GSFC.NASA.GOV Organization: The Internet Lines: 75 >> 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)? I thought the assembler was Interpreted code in all systems? Is this not true? So '"' is interactive and leaves on the stack the address of a copy of the string up to the next '"', which 'Is' eats and lays down the index entry, and then 'BX Push,' assembles the next instruction into the dictionary, and so on. >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. You are absolutely right about this. I take back my implication that my Is construct is in any way superior to { code . . . } " name" Def. It is in fact inferior (but easier, I think, to implament). >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 No problem, if we are talking about separate code and index spaces: CODE: " 2Push" Is BX PUSH CODE: " Next" Is AX PUSH CODE: " 1Push" Is ( Machinations for NEXT... ) ;Code This rewrite should make it obvious that we have factored out the HERE dependence only from Is/Def, and that CODE: (etc) still have it. This seems inherent in a state based system like FORTH (as opposed to a purely functional system). >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. I'm not sure why you say this. I am assuming Is does not compile anything into the dictionary, but my Code: is free to lay down a CFA and whatever code prefix it may find necessary, since it is called only once, at the beginning of the Word. Only "2Push" could be referenced as a FORTH word, the other two could only be used as assembly labels. For that reason I don't really consider my example valid code. Anyway, I concede that { some FORTH words } " Name" Def is more postfix than my Is. -- R. David Murray (DAVID@PENNDRLS.BITNET, DAVID@PENNDRLS.UPENN.EDU)