Execute SNUSP/Tcl: Difference between revisions

Added implementation notes
(Added implementation notes)
Line 1:
{{implementation|SNUSP}}{{collection|RCSNUSP}}[[Category:Tcl]]
This is an interpreter for [[SNUSP]]. Appears to work with correct SNUSP programs...
 
Historically, the Bloated interpreter was evolved from the Modular interpreter, which in turn was evolved from the Core interpreter.
 
The most interesting feature of the Core interpreter is that it models the data store as an unbounded half-line (implemented in a [[Tcl]] list), dynamically extending it “on the right” to have as many cells as necessary. Also, when a failure occurs (going outside the program space, going before the start of the data store) then a multi-level “break” exception is thrown to make the main loop exit.
 
The Modular interpreter adds a basic stack; it is not very much more interesting than the Core interpreter but was immediately evolved from it in order to be able to read the majority of SNUSP programs that exist out there (this is the most common dialect).
 
The Bloated interpreter is considerably more complex, but most of this complexity is limited to the outer parts of the main loop (plus the change in addressing model for the data store, which becomes an unbounded quarter plane). The principal interesting feature is the use of a dictionary to hold the thread-specific values, together with the use of <tt>dict with</tt> to break these variables temporarily out into global variables for processing. The definition of the READ operation also had to change to become non-blocking so that non-availability of a character would not block other threads. In theory, this could have been done with native OS threads, but then the fairness constraints described in the SNUSP language definition would not have been respected. Thread termination is performed by simply deleting the thread's data from the dictionary of threads.
<br clear=all>
==Core [[SNUSP]]==
Anonymous user