a note on macros and automacros host mode (compiler) a big part of the target forth, especially the 8bit STC forth, is implemented using (optimizing) macros. macros are host forth words (compiler words) that compile code to the target buffer. the pic instruction set maps nicely to a forth virtual machine: most basic forth words result in one or two pic instructions, and macros allow for peephole optimizations which can reduce code size further. instead of using the 'immediate -- postpone' duo, i've opted for macros defined using name mangling. this is a syntactic extension to ordinary forth. the reason is twofold: * 'postpone' is rather verbose, and direct callable macros are more concise in nested macro code. * 'immediate' has a rather awkward semantics with host/target words: code generators are host words, while highlevel words are target code. so, the interpreter contains a feature that will give words with a ',' or '_' extension special semantics. (the word ',' is for adding to the target code buffer, while '_' is for adding to the host code buffer). this works both ways: in target mode, when a word 'x' is encountered at compile time, it will be compiled using a reference to the word 'x' or by executing the macro 'x,' whichever is newer. (the same goes for 'x_' in host mode). in host mode, when a word 'x,' is encountered during the compilation of a new macro, either a call to the macro is compiled, or code is compiled which when executed compiles a call to the word 'x'. this is 'postpone' behaviour (compile compilation semantics) and is called 'automacros' in badnop. so, this gives a concise way of nesting macros, withouth having to bother why a given word is a macro or not: words ending in , (or _) always compile target (host) code. macro mode in this mode, the name attributes are hidden. all the words encountered have implicit postpone status. both examples below are equivalent: macro : x dup 123 + ; host : x, dup, 123 lit, +, ; this is in order to simplify simple subsitution macros for target code programming. in the metacompiler, it is necessary to make a distinction between the host forth and target macros. while this mechanism is very powerful, in simple target code this is usually not necessary: a more convenient mechanism there is to be able to substitute plain code with macros without having to use compiler syntax, so this can be done by using 'macro' and 'target' words to switch the compilation mode. in macro mode, words ending in '%' will always be executed. this can be used to override some host interpreted words, and target macros. (see stc/target.f). in macro mode, you can still use [ and ] to switch to interpret mode to access the compiler directly.