cmake: supernova - missing include_directories() for Jack
[supercollider.git] / Help / Core / Kernel / Interpreter.html
blob47ae3335906b2dbc7cadf615a1f9cbf18460269b
1 <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
2 <html>
3 <head>
4 <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
5 <meta http-equiv="Content-Style-Type" content="text/css">
6 <title></title>
7 <meta name="Generator" content="Cocoa HTML Writer">
8 <meta name="CocoaVersion" content="949.35">
9 <style type="text/css">
10 p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 18.0px Helvetica}
11 p.p2 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; min-height: 14.0px}
12 p.p3 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
13 p.p4 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #000000}
14 p.p5 {margin: 0.0px 0.0px 0.0px 0.0px; font: 14.0px Helvetica}
15 p.p6 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #606060}
16 p.p7 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica; color: #000000}
17 p.p8 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #bf0000}
18 p.p9 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; color: #000000; min-height: 16.0px}
19 p.p10 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Monaco; min-height: 16.0px}
20 span.s1 {text-decoration: underline}
21 span.s2 {color: #0000bf}
22 span.s3 {color: #000000}
23 span.s4 {color: #606060}
24 span.s5 {font: 12.0px Helvetica; color: #000000}
25 span.s6 {color: #0000ff}
26 span.s7 {color: #bf0000}
27 </style>
28 </head>
29 <body>
30 <p class="p1"><b>Interpreter</b></p>
31 <p class="p2"><br></p>
32 <p class="p3"><b>superclass: Object</b></p>
33 <p class="p2"><br></p>
34 <p class="p3">The interpreter defines a context in which interactive commands are compiled and executed.</p>
35 <p class="p2"><br></p>
36 <p class="p3">In the interpreter, <span class="s1">this</span> refers to the interpreter itself, e.g.:</p>
37 <p class="p2"><br></p>
38 <p class="p4"><span class="s2">this</span>.postln</p>
39 <p class="p2"><br></p>
40 <p class="p2"><br></p>
41 <p class="p5"><b><span class="s1">Accessing</span></b></p>
42 <p class="p2"><br></p>
43 <p class="p3">The interpreter defines instance variables 'a' through 'z' which are always available in the interpreter. By convention, the variable 's' is used to hold the default <b>Server</b>. Assigning another value to 's' may cause some of the examples in the documentation to fail.<span class="Apple-converted-space"> </span></p>
44 <p class="p2"><br></p>
45 <p class="p3"><b>clearAll</b></p>
46 <p class="p2"><br></p>
47 <p class="p3">set the values of the variables 'a' through 'z' to nil.</p>
48 <p class="p2"><br></p>
49 <p class="p4">(</p>
50 <p class="p4">x = 123;</p>
51 <p class="p4">x.postln;</p>
52 <p class="p4"><span class="s2">this</span>.clearAll;</p>
53 <p class="p4">x.postln;</p>
54 <p class="p4">)</p>
55 <p class="p2"><br></p>
56 <p class="p2"><br></p>
57 <p class="p5"><b><span class="s1">Compile &amp; Interpret</span></b></p>
58 <p class="p2"><br></p>
59 <p class="p3"><b>interpret(aString)</b></p>
60 <p class="p2"><br></p>
61 <p class="p3">Compile and execute a String.</p>
62 <p class="p2"><br></p>
63 <p class="p6"><span class="s2">this</span><span class="s3">.interpret(</span>"(123 + 4000).postln"<span class="s3">);</span></p>
64 <p class="p2"><br></p>
65 <p class="p3"><b>interpretPrint(aString)</b></p>
66 <p class="p2"><br></p>
67 <p class="p3">Compile and execute a String, printing the result.</p>
68 <p class="p2"><br></p>
69 <p class="p4"><span class="s2">this</span>.interpretPrint(<span class="s4">"123 + 4000"</span>);</p>
70 <p class="p2"><br></p>
71 <p class="p2"><br></p>
72 <p class="p3"><b>compile(aString)</b></p>
73 <p class="p2"><br></p>
74 <p class="p3">Compile a String and return a Function.</p>
75 <p class="p2"><br></p>
76 <p class="p7">(</p>
77 <p class="p6"><span class="s5">z = </span><span class="s2">this</span><span class="s3">.compile(</span>"(123 + 4000).postln"<span class="s3">);</span></p>
78 <p class="p4">z.postln;</p>
79 <p class="p4">z.value;</p>
80 <p class="p4">)</p>
81 <p class="p2"><br></p>
82 <p class="p3"><b>compileFile(pathName)</b></p>
83 <p class="p2"><br></p>
84 <p class="p3">Reads the file at pathName, compiles it and returns a Function.<span class="Apple-converted-space"> </span></p>
85 <p class="p3">The file must contain a valid SuperCollider expression, naturally.</p>
86 <p class="p3">This will not compile class definitions, only expressions.</p>
87 <p class="p2"><br></p>
88 <p class="p3"><b>executeFile(pathName)</b></p>
89 <p class="p2"><br></p>
90 <p class="p3">Reads the file at pathName, compiles it and executes it, returning the result.<span class="Apple-converted-space"> </span></p>
91 <p class="p3">The file must contain a valid SuperCollider expression, naturally.</p>
92 <p class="p3">This will not compile class definitions, only expressions.</p>
93 <p class="p2"><br></p>
94 <p class="p3"><b>cmdLine</b></p>
95 <p class="p2"><br></p>
96 <p class="p3">Returns the previosly interpreted code.</p>
97 <p class="p2"><br></p>
98 <p class="p4">(</p>
99 <p class="p4">1 + 2;</p>
100 <p class="p4"><span class="s2">this</span>.cmdLine</p>
101 <p class="p4">)</p>
102 <p class="p2"><br></p>
103 <p class="p3"><b>codeDump</b></p>
104 <p class="p2"><br></p>
105 <p class="p3">this interpreter variable can be set to evaluate a function with any sucessfully compiled code.</p>
106 <p class="p3">see e.g. the class <a href="../../Libraries/JITLib/extras/History.html"><span class="s6">History</span></a>.</p>
107 <p class="p2"><br></p>
108 <p class="p8"><span class="s3">a = [ ]; </span>// store all the code evaulated in a</p>
109 <p class="p4"><span class="s2">this</span>.codeDump = { <span class="s2">|code|</span> a = a.add(code) };</p>
110 <p class="p4">1 + 3;</p>
111 <p class="p4">f = { <span class="s4">"hallo"</span> };</p>
112 <p class="p4">a.postcs;</p>
113 <p class="p8"><span class="s3">codeDump = </span><span class="s2">nil</span><span class="s3">; </span>// reset to nil.</p>
114 <p class="p2"><br></p>
115 <p class="p2"><br></p>
116 <p class="p3"><b>preProcessor</b></p>
117 <p class="p2"><br></p>
118 <p class="p3">can be used to modify code before it is interpreted. Given appropriate delimiters, this can be used to implement little languages.</p>
119 <p class="p2"><br></p>
120 <p class="p8">// silly but simple: understand a Saw for every SinOsc</p>
121 <p class="p4"><span class="s2">this</span>.preProcessor = { <span class="s2">|code|</span> code.replace(<span class="s4">"SinOsc"</span>, <span class="s4">"Saw"</span>) };</p>
122 <p class="p9"><br></p>
123 <p class="p4">{ <span class="s2">SinOsc</span>.ar(200) * 0.1 }.play;</p>
124 <p class="p9"><br></p>
125 <p class="p4">preProcessor = <span class="s2">nil</span>; <span class="s7">// reset to nil.</span></p>
126 <p class="p10"><br></p>
127 <p class="p10"><br></p>
128 <p class="p10"><br></p>
129 </body>
130 </html>