Skip to content
L.Schmidt edited this page Feb 28, 2022 · 31 revisions
  • concepts:

    • forward referencing of words, either only those compiled to new words, or also those called upon while interpreting. Feature can be enabled and disabled any time (disabled by default)
    • not exactly a purely incremental compiler
      • semicolon triggers compilation. Up to then are words only buffered. This allows the compiler to do post processing the word, useful for
        • replacing code sequences against more efficient functional equivalents.
        • delegating some compilation tasks from words to post processing. For example, create ... does> defining words are ripped apart by the post processor. The run time "does>" part is stored separately, to give the define time words semantics applicator easier access to run time code. Mind you, this is bash targeted, which doesn't allow to simply point instruction pointer inside of a function.
  • specific words where deviating from ANS:

    • query doesn't exist. Instead there's query$ which utilises string stack to store input.
    • evaluate not exposed. Instead, evaluate$ takes input from string stack (where query$ puts it)
    • quit can't do a "real" warm start. It just - optionally - empties stacks, then nests to a new instance of quit. Not a problem as long as it loops in its infinite loop, but you may want to avoid tapping ctrl-c thousands of times).
    • r> >r return stack is not used to hold return addresses. yoda won't complain if "return stack" is used in an unbalanced way.
    • convert, uconvert ( n / u -- ) ( string: -- $1 ) convert signed or unsigned numeric n or u to string, pushed to string stack
    • from / from$ include yoda source code While from parses a space delimited string from input, from$ takes file name from string stack. Files without slash in their name are searched for through list of library dirs (configuration item).
  • Implementation

    • strings. An additional string stack has been added, entering strings doesn't go through s" word. Instead are strings recognised and dealt with by a pattern matching mechanism, invoked on words not found in the dictionary. Literal numbers, ASCII values of single characters, shell commands are subject to the same mechanism.
    • there is no virtual machine. Compiling a word creates a bash function, containing, from a bash viewpoint, "native code". The yoda interpreter operates within the same shell environment as the functions its compiler generates - yoda doesn't shell (unless bash does for invoking an external command).
    • Due to its forward referencing capability does yoda not need all of the functionality necessary for compiling a program already prior to beginning of compilation. Instead can it resolve those after compilation on a need-to-include base. This allows for a more automatic and comfortable library inclusion management.
    • yoda has now eliminated immediate words and replaced against word in context wordlists compileonly and interpretonly, limiting the scope to those such marked words to compiling resp. interpreting. Word in compileonly wordlist will be executed just as well, thereby mimicking words set immediate. Still the word "immediate" exists. It is used to place header of a word marked as such into both compileonly as well as interpretonly wordlists, thereby mimicking immediate words even closer.

Clone this wiki locally