Execute SNUSP/Tcl: Difference between revisions

m
Fixed syntax highlighting.
m (Make more consistent)
m (Fixed syntax highlighting.)
 
(2 intermediate revisions by 2 users not shown)
Line 1:
{{implementation|SNUSP}}{{collection|RCSNUSP}}[[implementation of task::RCSNUSP| ]]
These are [[Tcl]] interpreters for [[SNUSP]], and they appear to work with correct SNUSP programs.
 
Line 10:
The interpreter for '''Bloated''' SNUSP 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]]===
<langsyntaxhighlight lang="tcl">package require Tcl 8.5
 
# Basic I/O to read the program data and get ready for execution
Line 89:
Move
}
if {$last != 10} {puts ""}</langsyntaxhighlight>
 
===Modular [[SNUSP]]===
<langsyntaxhighlight lang="tcl">package require Tcl 8.5
 
# Basic I/O to read the program data and get ready for execution
Line 190:
Move
}
if {$last != 10} {puts ""}</langsyntaxhighlight>
 
===Bloated [[SNUSP]]===
<langsyntaxhighlight lang="tcl">package require Tcl 8.5
# Basic I/O to read the program data and get ready for execution
Line 327:
}
}
if {$last != 10} {puts ""}</langsyntaxhighlight>
===Test Code===
====Samples of Bloated SNUSP====
This prints out a random number of random length:
<pre><nowiki>$!/+++++++++%++++++++++++++++++++++++++++++++++++++++++++++++.!/-\
9,476

edits