Re: [stack] things
eas lab <[email protected]>
| Newsgroups | gmane.comp.lang.concatenative |
|---|---|
| Message-ID | <[email protected]> |
Dennis wrote:- * To define a word -- meaning binding name to code block -- the format > name : block > maps to > (name (block)) > or in Forth to > :name block; It might help you to first know a bit how forth DOES work: * tokens in the source are separated by white-spaces. So ':name' is ONE token. But ': name' is TWO tokens meaning: ':' =I'm starting a definition to be entered into the dictionary & the next token [ignore possible exceptions] will be the ID of this new definition. > * End of lines mark the end of a word definition. > They are thus a top-level nesting separator inside a > thing literal. So that > > (a b c > d e f) > maps to > ((abc)(def)) eol is a unique, very-valuable char for human recognition. Why do you want to waste it to do what ")" seems to be capable of doing. --snip-- > Do "does" code that should be on the stack (if the code > is a defined word, it may be referenced instead). > > :writeOne 1 write > in Forth could written > writeOne : 1 push write push do pop pop This seems to do: 1 = create '1', perhaps like forth: by recognising that it's an integer, which is VERY different from a word in the dictionary. push = is a reserved-word/meta-primitives which pushes the previous input-token. forth automatically pushes any number. Apparenty you shouldn't 'mention' it unless you intend to push it. If you don't want to push the "1", how else would you want to use it ? If you don't want to 'use/do' "write" why do you evoke it ? But actually, you're OK, since I'm talking about optimising, which you should not do too early. So OK, '2 push' '3 push' '+ do' 'write do'; you would later optimise to '2 3 + .', as you got to better understand the 'structure'. What you seem to be doing is interesting: avoiding reading what the forth inner-interpreter does and making your own inner-interpreter. Apparently you are describing the parser/inner- interpreter. Which you're merging with the next stage. In computing we normally separate the layers. Not like also below where you merge the stack & the accumulator conceptually. With current technology, data transformation eg. addition can ONLY be done in an ALU. And the stack is only passive memory. So when the 'operations are done to the TOS' this is only virtually. In order to handle the mental complexity, we separate the process into different [isolated] conceptual layers. You are merging the layers. If I see mickey mouse dancing on my screen, the underlying pixels and electronic signals are at different conceptual levels. == Chris Glur.