2 summary:: The interpreter defines a context in which interactive commands are compiled and executed.
3 categories:: Core>Kernel
6 In the interpreter, code::this:: refers to the interpreter itself, e.g.: code::this.postln::
16 The interpreter defines instance variables code::a:: through code::z:: which are always available in the interpreter. By convention, the variable code::s:: is used to hold the default Server. Assigning another value to code::s:: may cause some of the examples in the documentation to fail.
20 set the values of the variables code::a:: through code::z:: to nil.
29 subsection::Compile & Interpret
33 Compile and execute a link::Classes/String::.
36 this.interpret("(123 + 4000).postln");
39 method::interpretPrint
41 Compile and execute a link::Classes/String::, printing the result.
44 this.interpretPrint("123 + 4000");
49 Compile a String and return a link::Classes/Function::.
53 z = this.compile("(123 + 4000).postln");
61 Reads the file at pathName, compiles it and returns a Function.
62 The file must contain a valid SuperCollider expression, naturally.
63 This will not compile class definitions, only expressions.
67 Reads the file at pathName, compiles it and executes it, returning the result.
68 The file must contain a valid SuperCollider expression, naturally.
69 This will not compile class definitions, only expressions.
73 Returns the previosly interpreted code.
82 this interpreter variable can be set to evaluate a function with any sucessfully compiled code.
83 see e.g. the class History.
86 a = [ ]; // store all the code evaulated in a
87 this.codeDump = { |code| a = a.add(code) };
91 codeDump = nil; // reset to nil.
96 can be used to modify code before it is interpreted. Given appropriate delimiters, this can be used to implement little languages.
99 // silly but simple: understand a Saw for every SinOsc
100 this.preProcessor = { |code| code.replace("SinOsc", "Saw") };
102 { SinOsc.ar(200) * 0.1 }.play;
104 preProcessor = nil; // reset to nil.