996
|
1 <HTML>
|
|
2 <HEAD>
|
|
3 <TITLE>CLC-INTERCAL Reference</TITLE>
|
|
4 </HEAD>
|
|
5 <BODY>
|
|
6 <H1>CLC-INTERCAL Reference</H1>
|
|
7 <H2>... Statements</H2>
|
|
8
|
|
9 <P>
|
|
10 The statements are described in an order which minimises forward references.
|
|
11 In other words, the first time you read this page go from beginning to end.
|
|
12 For easy reference, an alphabetic list follows. See the description for the
|
|
13 various statements to determine which compilers support them.
|
|
14 </P>
|
|
15
|
|
16 <P>
|
|
17 Table of contents:
|
|
18 <UL>
|
|
19 <LI><A HREF="index.html">Parent directory</A>
|
|
20 <LI><A HREF="#abstain_from">ABSTAIN FROM</A>
|
|
21 <LI><A HREF="#calculate">Calculate</A>
|
|
22 <LI><A HREF="#case">CASE</A>
|
|
23 <LI><A HREF="#come_from">COME FROM</A>
|
|
24 <LI><A HREF="#comments">Comments</A>
|
|
25 <LI><A HREF="#convert">CONVERT</A>
|
|
26 <LI><A HREF="#create">CREATE</A>
|
|
27 <LI><A HREF="#destroy">DESTROY</A>
|
|
28 <LI><A HREF="#enrol">ENROL</A>
|
|
29 <LI><A HREF="#enslave">ENSLAVE</A>
|
|
30 <LI><A HREF="#finish_lecture">FINISH LECTURE</A>
|
|
31 <LI><A HREF="#forget">FORGET</A>
|
|
32 <LI><A HREF="#free">FREE</A>
|
|
33 <LI><A HREF="#give_up">GIVE UP</A>
|
|
34 <LI><A HREF="#graduates">GRADUATES</A>
|
|
35 <LI><A HREF="#ignore">IGNORE</A>
|
|
36 <LI><A HREF="#learns">LEARNS</A>
|
|
37 <LI><A HREF="#next">NEXT</A>
|
|
38 <LI><A HREF="#next_from">NEXT FROM</A>
|
|
39 <LI><A HREF="#read_out">READ OUT</A>
|
|
40 <LI><A HREF="#reinstate">REINSTATE</A>
|
|
41 <LI><A HREF="#remember">REMEMBER</A>
|
|
42 <LI><A HREF="#resume">RESUME</A>
|
|
43 <LI><A HREF="#retrieve">RETRIEVE</A>
|
|
44 <LI><A HREF="#steal">SMUGGLE</A>
|
|
45 <LI><A HREF="#stash">STASH</A>
|
|
46 <LI><A HREF="#steal">STEAL</A>
|
|
47 <LI><A HREF="#study">STUDY</A>
|
|
48 <LI><A HREF="#swap">SWAP</A>
|
|
49 <LI><A HREF="#while">WHILE</A>
|
|
50 <LI><A HREF="#write_in">WRITE IN</A>
|
|
51 </UL>
|
|
52 </P>
|
|
53
|
|
54 <H2><A NAME="comments">Comments</A></H2>
|
|
55
|
|
56 <P>
|
|
57 Any statement which cannot be recognised is simply inserted in the compiled
|
|
58 program. Executing this statement is very likely to be an error, however
|
|
59 one can make sure the comments are ABSTAINed FROM (see below), so they
|
|
60 won't be executed.
|
|
61 </P>
|
|
62
|
|
63 <P>
|
|
64 The following statement is initially ABSTAINed FROM (because of the word
|
|
65 "NOT" as a prefix of "NOTE"):
|
|
66 <PRE>
|
|
67 PLEASE NOTE THAT WE DO NOT KNOW WHAT WE ARE TALKING ABOUT
|
|
68 </PRE>
|
|
69 (in fact, this example contains two statements, but this is OK as they
|
|
70 are both ABSTAINed FROM).
|
|
71 </P>
|
|
72
|
|
73 <P>
|
|
74 If a comment is executed, it is printed as an error message. For example,
|
|
75 <PRE>
|
|
76 DO YOU REALISE THAT USING INTERCAL IS BAD FOR YOUR SANITY?
|
|
77 PLEASE DO SOMETHING ELSE.
|
|
78 </PRE>
|
|
79 would print the first line and terminate the program (the second
|
|
80 line is understood by the compiler as a separate statement,
|
|
81 which does not get executed because the first line terminates
|
|
82 the program).
|
|
83 </P>
|
|
84
|
|
85 <P>
|
|
86 Comments usually correspond to a splat code 0. Other error codes are
|
|
87 listed in <A HREF="errors.html">the chapter about Errors</A>.
|
|
88 </P>
|
|
89
|
|
90 <H2><A NAME="calculate">Calculate</A></H2>
|
|
91
|
|
92 <P>
|
|
93 This statement has the form of a register name, a left arrow
|
|
94 (<CODE><-</CODE>) and an expression. The effect is to assign the value
|
|
95 of the expression to the register.
|
|
96 </P>
|
|
97
|
|
98 <P>
|
|
99 Examples:<BR>
|
|
100 <CODE>DO .1 <- #3</CODE><BR>
|
|
101 <CODE>DO ,1 SUB .1 SUB .2 <- .3~#3</CODE>
|
|
102 </P>
|
|
103
|
|
104 <P>
|
|
105 If the left-hand side contains an array without subscripts, this statement
|
|
106 will dimension the array (or redimension it, throwing away the old contents).
|
|
107 In this case, it is possible to specify multidimensional arrays by including
|
|
108 more than one expression, separated by the keyword "BY".
|
|
109 </P>
|
|
110
|
|
111 <P>
|
|
112 Example:<BR>
|
|
113 <CODE>DO ,1 <- #3 BY #4 BY .1</CODE><BR>
|
|
114 CLC-INTERCAL 1.-94.-4 and newer allows to assign to constants,
|
|
115 or indeed to any expression (when the compiler is sick). This
|
|
116 result has always been possible using overloading, but it is now
|
|
117 easier to achieve.
|
|
118 </P>
|
|
119
|
|
120 <P>
|
|
121 Examples:<BR>
|
|
122 <CODE>DO #1 <- #3</CODE><BR>
|
|
123 <CODE>DO .1 <- #4</CODE><BR>
|
|
124 assigns #3 to #1 and then assigns #4 to .3
|
|
125 (because the value of the "1" in .1 is now 3).
|
|
126 </P>
|
|
127
|
|
128 <P>
|
|
129 Examples:<BR>
|
|
130 <CODE>DO .2 <- #1</CODE><BR>
|
|
131 <CODE>DO #1 <- #3</CODE><BR>
|
|
132 <CODE>DO #3 <- .1</CODE><BR>
|
|
133 swaps the values of #1 and #3.
|
|
134 </P>
|
|
135
|
|
136 <P>
|
|
137 Quantum INTERCAL allows the programmer to do and not-do the
|
|
138 assignment at the same time using syntax <CODE>DO .1 <- #2 WHILE NOT
|
|
139 ASSIGNING TO IT</CODE>. This is described in more detail in
|
|
140 <A HREF="quantum.html">the chapter about Quantum INTERCAL</A>.
|
|
141 </P>
|
|
142
|
|
143 <H2><A NAME="ignore">IGNORE</A></H2>
|
|
144
|
|
145 <P>
|
|
146 The keyword "IGNORE" is followed by a list of registers,
|
|
147 separated by intersection (<CODE>+</CODE>). After this, any
|
|
148 attempt to modify the values of the registers will be silengly
|
|
149 ignored, but any side effect will still happen, so if you try to
|
|
150 WRITE IN an ignored register you discard some input, and if you
|
|
151 assign an expression containing overloading you still execute the
|
|
152 overloading; however, if you try to overload in IGNOREd register,
|
|
153 this overloading won't be applied.
|
|
154 </P>
|
|
155
|
|
156 <P>
|
|
157 Note that you can IGNORE whole arrays, but not single subscripts.
|
|
158 </P>
|
|
159
|
|
160 <P>
|
|
161 The effect of IGNORE ceases when a REMEMBER lists the same registers.
|
|
162 </P>
|
|
163
|
|
164 <P>
|
|
165 Examples:<BR>
|
|
166 <CODE>IGNORE .1 + ,1 + :3</CODE><BR>
|
|
167 <CODE>IGNORE $49.99</CODE>
|
|
168 <P>
|
|
169
|
|
170 <P>
|
|
171 Quantum INTERCAL allows the programmer to set the "ignore" state of a
|
|
172 variable to both true and false symultaneously, for example:<BR>
|
|
173 <CODE>IGNORE .1 + ,1 + :3 WHILE REMEMBERING THEM</CODE><BR>
|
|
174 <CODE>IGNORE $49.99 WHILE REMEMBERING IT</CODE><BR>
|
|
175 This is described in more detail in <A HREF="quantum.html">the
|
|
176 chapter about Quantum INTERCAL</A>.
|
|
177 </P>
|
|
178
|
|
179 <H2><A NAME="remember">REMEMBER</A></H2>
|
|
180
|
|
181 <P>
|
|
182 The keyword is followed by a list of registers, separated by intersection
|
|
183 (<CODE>+</CODE>). It undoes the effect of an IGNORE on those registers, so
|
|
184 subsequent changes will affect them. It is not an error to REMEMBER a
|
|
185 register which had not been IGNOREd. It is possible to follow the list
|
|
186 with <CODE>WHILE IGNORING THEM</CODE> to produce a program which
|
|
187 simultaneously remembers and ignores the registers: see
|
|
188 <A HREF="quantum.html">the chapter about Quantum INTERCAL</A>.
|
|
189 </P>
|
|
190
|
|
191 <H2><A NAME="abstain_from">ABSTAIN FROM</A></H2>
|
|
192
|
|
193 <P>
|
|
194 This is followed by either a label or a list of gerunds separated by
|
|
195 intersection (<CODE>+</CODE>). The statement corresponding to that label,
|
|
196 or all statements corresponding to the gerunds, will not be executed from
|
|
197 now on (until a REINSTATE is executed).
|
|
198 </P>
|
|
199
|
|
200 <P>
|
|
201 It is not possible to ABSTAIN FROM GIVING UP. If you ABSTAIN FROM a label,
|
|
202 and that happens to be a GIVE UP statement, this is silently ignored.
|
|
203 </P>
|
|
204
|
|
205 <P>
|
|
206 For example, the following program will assign 12 to register <CODE>.1</CODE>
|
|
207 <PRE>
|
|
208 PLEASE ABSTAIN FROM (1)
|
|
209 (1) DO ABSTAIN FROM CALCULATING + ABSTAINING
|
|
210 DO .1 <- #12
|
|
211 DO ABSTAIN FROM (2)
|
|
212 (2) DO .1 <- #4
|
|
213 PLEASE GIVE UP
|
|
214 </PRE>
|
|
215 </P>
|
|
216
|
|
217 <P>
|
|
218 It is possible to ABSTAIN FROM ABSTAINING. It is also possible to ABSTAIN
|
|
219 FROM REINSTATING, although we do not recommend it.
|
|
220 </P>
|
|
221
|
|
222 <P>
|
|
223 The presence of a negative (<CODE>NOT</CODE>, <CODE>N'T</CODE> or
|
|
224 <CODE>¬</CODE>) before a statement will cause it to be initially
|
|
225 ABSTAINED FROM, so the above program is equivalent to:
|
|
226 <PRE>
|
|
227 DO NOT ABSTAIN FROM CALCULATING + ABSTAINING
|
|
228 DO .1 <- #12
|
|
229 DO NOT .1 <- #4
|
|
230 PLEASE GIVE UP
|
|
231 </PRE>
|
|
232 </P>
|
|
233
|
|
234 <P>
|
|
235 Which in turn is the same as:
|
|
236 <PRE>
|
|
237 DO .1 <- #12
|
|
238 PLEASE GIVE UP
|
|
239 </PRE>
|
|
240 </P>
|
|
241
|
|
242 <P>
|
|
243 CLC-INTERCAL 1.-94 introduced ABSTAIN FROM COMMENTING, which ABSTAINs from
|
|
244 anything the compiler finds unparseable. THere is a corresponding
|
|
245 REINSTATE COMMENTING.
|
|
246 </P>
|
|
247
|
|
248 <P>
|
|
249 If you have a quantum computer, you can simultaneously ABSTAIN
|
|
250 and REINSTATE a statement or a list of gerunds:
|
|
251 <PRE>
|
|
252 PLEASE ABSTAIN FROM (1) WHILE REINSTATING IT
|
|
253 (1) DO ABSTAIN FROM CALCULATING + ABSTAINING WHILE REINSTATING THEM
|
|
254 DO ABSTAIN FROM CALCULATING WHILE REINSTATING IT
|
|
255 PLEASE GIVE UP
|
|
256 </PRE>
|
|
257 This is described in more detail in <A HREF="quantum.html">the
|
|
258 chapter about Quantum INTERCAL</A>.
|
|
259 </P>
|
|
260
|
|
261 <P>
|
|
262 A recent improvement to the Quantum INTERCAL engine allows to
|
|
263 ABSTAIN FROM QUANTUM COMPUTING, which would make all quantum
|
|
264 statement behave like classical ones, and the corresponding
|
|
265 REINSTATE QUANTUM COMPUTING. And of course, one can ABSTAIN FROM
|
|
266 QUANTUM COMPUTING WHILE REINSTATING IT.
|
|
267 </P>
|
|
268
|
|
269 <P>
|
|
270 One last extension (in CLC-INTERCAL 0.05) allows to specify an expression
|
|
271 instead of a label; and a statement template instead of a gerund. For example:
|
|
272 <PRE>
|
|
273 DO ABSTAIN FROM REGISTER <- EXPRESSION
|
|
274 + REMEMBER REGISTER LIST
|
|
275 + IGNORE REGISTER LIST
|
|
276 </PRE>
|
|
277 is equivalent to:
|
|
278 <PRE>
|
|
279 DO ABSTAIN FROM CALCULATING + REMEMBERING + IGNORING
|
|
280 </PRE>
|
|
281 </P>
|
|
282
|
|
283 <P>
|
|
284 However, statement templates give finer control than gerunds. For example,
|
|
285 after:
|
|
286 <PRE>
|
|
287 DO ABSTAIN FROM ABSTAIN FROM LABEL + REINSTATE GERUND LIST
|
|
288 </PRE>
|
|
289 an "ABSTAIN FROM (2)" or "REINSTATE ABSTAINING" would be ignored, but
|
|
290 "ABSTAIN FROM REINSTATING" and "REINSTATE (3)" would be still executed.
|
|
291 </P>
|
|
292
|
|
293 <H2><A NAME="reinstate">REINSTATE</A></H2>
|
|
294
|
|
295 <P>
|
|
296 Followed by the same kind of things you can say after
|
|
297 "ABSTAIN FROM", undoes the effects of ABSTAINING FROM these
|
|
298 things. CLC-INTERCAL 0.05 or later allows an expression instead
|
|
299 of a label, and a statement template instead of a gerund.
|
|
300 </P>
|
|
301
|
|
302 <P>
|
|
303 You can REINSTATE REINSTATING, and it does make sense - maybe you want to
|
|
304 make sure that any REINSTATE which was ABSTAINED FROM by label is
|
|
305 REINSTATEd. You cannot REINSTATE GIVING UP, not even by label.
|
|
306 </P>
|
|
307
|
|
308 <P>
|
|
309 Quantum program might wish to add <CODE>WHILE ABSTAINING FROM IT</CODE>
|
|
310 (or <CODE>WHILE ABSTAINING FROM THEM</CODE>). See <A HREF="quantum.html">the
|
|
311 chapter about Quantum INTERCAL</A>.
|
|
312 </P>
|
|
313
|
|
314 <P>
|
|
315 CLC-INTERCAL 0.05 and newer allows to REINSTATE templates, with a syntax
|
|
316 similar to ABSTAIN FROM templates.
|
|
317 </P>
|
|
318
|
|
319 <P>
|
|
320 CLC-INTERCAL 1.-94 allows to REINSTATE COMMENTING. You probably don't want
|
|
321 to do that, but it's there if you need it.
|
|
322 Note that there is no template corresponding to this gerund.
|
|
323 </P>
|
|
324
|
|
325 <H2><A NAME="come_from">COME FROM</A></H2>
|
|
326
|
|
327 <P>
|
|
328 This is the main program control statement in CLC-INTERCAL. It is followed by
|
|
329 either a label or an expression. When the execution reaches the label (or
|
|
330 a label with the same value as the expression), it will run the current
|
|
331 statement and then jump to the COME FROM. For example, this is a subroutine
|
|
332 call, in which register <CODE>.1</CODE> is used to hold the "return address"
|
|
333 and register <CODE>.2</CODE> to hold the "subroutine address":
|
|
334 <PRE>
|
|
335 DO .1 <- #1000
|
|
336 (100) DO .2 <- #100
|
|
337 PLEASE COME FROM .1
|
|
338 DO .1 <- #0
|
|
339
|
|
340 ...
|
|
341
|
|
342 PLEASE COME FROM .2
|
|
343 DO .2 <- #0
|
|
344 ...
|
|
345 (1000) DON'T PANIC
|
|
346 </PRE>
|
|
347 </P>
|
|
348
|
|
349 <P>
|
|
350 The assignment of <CODE>#100</CODE> to <CODE>.2</CODE> causes an immediate
|
|
351 jump to the subroutine. At the end of the subroutine, after the
|
|
352 no-op (DON'T PANIC does nothing because it is ABSTAINed FROM), the program
|
|
353 jumps back to the COME FROM <CODE>.1</CODE>. We assign zero to the pointers
|
|
354 just after use to avoid problems when the subroutine is called in more than
|
|
355 one place.
|
|
356 </P>
|
|
357
|
|
358 <P>
|
|
359 It is an error to have multiple COME FROMs pointing at the same label (unless the
|
|
360 <I>thick</I> compiler option is in operation). However,
|
|
361 if all except one are ABSTAINed FROM, this is not a problem. So the above
|
|
362 program can be rewritten as:
|
|
363 <PRE>
|
|
364 DO REINSTATE (101)
|
|
365 (100) DO .2 <- #100
|
|
366 (101) PLEASE DON'T COME FROM (1000)
|
|
367 DO ABSTAIN FROM (101)
|
|
368
|
|
369 ...
|
|
370
|
|
371 PLEASE COME FROM .2
|
|
372 DO .2 <- #0
|
|
373 ...
|
|
374 (1000) DON'T PANIC
|
|
375 </PRE>
|
|
376 or even without computed COME FROMs (although this requires to change the
|
|
377 subroutine every time you add a call - this way of removing computed COME
|
|
378 FROMs is best left to the optimiser):
|
|
379 <PRE>
|
|
380 DO REINSTATE (1001)
|
|
381 (100) DO REINSTATE (101)
|
|
382 (101) PLEASE DON'T COME FROM (1000)
|
|
383 DO ABSTAIN FROM (101)
|
|
384 DO ABSTAIN FROM (1001)
|
|
385
|
|
386 ...
|
|
387
|
|
388 (1001) PLEASE DO NOT COME FROM (100)
|
|
389 ...
|
|
390 (1000) DON'T PANIC
|
|
391 </PRE>
|
|
392 </P>
|
|
393
|
|
394 <P>
|
|
395 The simple program to implement a stack and allow recursive subroutines using
|
|
396 this technique is left as an exorcism (sic) to the reader.
|
|
397 </P>
|
|
398
|
|
399 <P>
|
|
400 CLC-INTERCAL 1.-94 introduces COME FROM GERUND (and NEXT FROM GERUND): for
|
|
401 example:
|
|
402 <PRE>
|
|
403 PLEASE COME FROM COMING FROM
|
|
404 </PRE>
|
|
405 causes an infinite loop because the statement keeps reexecuting (and COMING
|
|
406 FROM itself!). Since there are runtime overheads associated with COME FROM
|
|
407 GERUND, it must be requested by the compiler option <I>come-from-gerund</I>. And of
|
|
408 course, templates can be used instead of gerunds, just like the ABSTAIN FROM and REINSTATE statements.
|
|
409 </P>
|
|
410
|
|
411 <P>
|
|
412 When the <I>thick</I> compiler option is in operation, multiple COME FROMs
|
|
413 all pointing at the same label will cause the program to start as many
|
|
414 threads as necessary so it gan go to all those places.
|
|
415 </P>
|
|
416
|
|
417 <P>
|
|
418 When using computed COME FROMs or computed labels, please
|
|
419 remember that if any of the expressions have side effects
|
|
420 (e.g. overloading), these side effects can appear in the most
|
|
421 unexpected places. See for example the
|
|
422 <A HREF="../examples/hello.i">Hello, World</A> program,
|
|
423 which works by having each of the computed COME FROM setting
|
|
424 up an overload to modify the way the other computed COME FROMs
|
|
425 behave. It is slightly confusing.
|
|
426 </P>
|
|
427
|
|
428 <P>
|
|
429 The Quantum variant of COME FROM adds a "WHILE NOT COMING FROM
|
|
430 THERE" at the end of the statement.
|
|
431 </P>
|
|
432
|
|
433 <H2><A NAME="next">NEXT</A></H2>
|
|
434
|
|
435 <P>
|
|
436 The keyword must be <EM>preceded</EM> by a label. It serves the function
|
|
437 of the GO TO statement of other languages, and can also be used for subroutine
|
|
438 calls. For this reason, it allow to write programs which look just like any
|
|
439 other language, and this is a Bad Idea. CLC-INTERCAL considers any programs
|
|
440 which use NEXT, FORGET or RESUME as obsolete, and will only run them if you
|
|
441 use the <I>next</I> option, or the <I>ick</I> or <I>1972</I> compiler.
|
|
442 </P>
|
|
443
|
|
444 <P>
|
|
445 Beginning with CLC-INTERCAL 0.05, the label preceding "NEXT" can be replaced
|
|
446 by an expression.
|
|
447 </P>
|
|
448
|
|
449 <P>
|
|
450 The effect of NEXT is to transfer control to the stated label, and also to
|
|
451 save a return address in an internal stack. See FORGET and RESUME below for
|
|
452 the rest of the story.
|
|
453 </P>
|
|
454
|
|
455 <P>
|
|
456 This is an example of subroutine call:
|
|
457 <PRE>
|
|
458 DO (1000) NEXT
|
|
459 ...
|
|
460 (1000) DO ....
|
|
461 PLEASE RESUME #1
|
|
462 </PRE>
|
|
463 </P>
|
|
464
|
|
465 <P>
|
|
466 The Quantum version of NEXT adds "WHILE NOT NEXTING" at the end of the statement.
|
|
467 </P>
|
|
468
|
|
469 <H2><A NAME="forget">FORGET</A></H2>
|
|
470
|
|
471 <P>
|
|
472 Followed by an expression. It evaluates the expression, then removes that
|
|
473 many return addresses from the stack managed by NEXT and RESUME. These
|
|
474 addresses are simply discarded. If you want to use NEXT as a GO TO, you
|
|
475 should FORGET #1 just afterwards so the stack does not overflow.
|
|
476 </P>
|
|
477
|
|
478 <P>
|
|
479 The Quantum version of FORGET adds "WHILE REMEMBERING" at the end of
|
|
480 the statement; for compatibility with previous versions of CLC-INTECAL,
|
|
481 "WHILE NOT FORGETTING" can also be used.
|
|
482 </P>
|
|
483
|
|
484 <H2><A NAME="resume">RESUME</A></H2>
|
|
485
|
|
486 <P>
|
|
487 Followed by an expression. It evaluates the expression, then removes that
|
|
488 many return addresses from the stack managed by NEXT and FORGET. After that,
|
|
489 it jumps to the last return address it removed. So RESUME #1 is a normal
|
|
490 return from subroutine, while RESUME #3 is equivalent to FORGET #2 followed
|
|
491 by RESUME #1.
|
|
492 </P>
|
|
493
|
|
494 <P>
|
|
495 The Quantum version of RESUME adds "WHILE NOT RESUMING" at the end of the statement.
|
|
496 </P>
|
|
497
|
|
498 <H2><A NAME="next_from">NEXT FROM</A></H2>
|
|
499
|
|
500 <P>
|
|
501 Like <CODE>COME FROM</CODE>, but it saves the return address, as a
|
|
502 <CODE>NEXT</CODE> would do. It has the same syntax as <CODE>COME FROM</CODE>:
|
|
503 <PRE>
|
|
504 PLEASE NEXT FROM (666)
|
|
505 ...
|
|
506 DO RESUME #1
|
|
507 </PRE>
|
|
508 </P>
|
|
509
|
|
510 <P>
|
|
511 Just after executing the statement with label (666) the program jumps to the
|
|
512 above fragment: at the end, it returns to the statement after the one with
|
|
513 the label (666).
|
|
514 </P>
|
|
515
|
|
516 <P>
|
|
517 The Quantum version of NEXT FROM uses the syntax "WHILE NOT NEXTING FROM THERE"
|
|
518 </P>
|
|
519
|
|
520 <H2><A NAME="stash">STASH</A></H2>
|
|
521
|
|
522 <P>
|
|
523 Followed by a list of registers, it copies them to some secret place for
|
|
524 safekeeping. You can stash whole arrays, but not single elements (well,
|
|
525 you can always assign the element to a register and then STASH that).
|
|
526 Note that not just the values are saved: the current BELONGS TO relation,
|
|
527 the current overloading, and the current IGNORE/REMEMBER state are also
|
|
528 saved. See RETRIEVE for the second half of the story.
|
|
529 </P>
|
|
530
|
|
531 <H2><A NAME="retrieve">RETRIEVE</A></H2>
|
|
532
|
|
533 <P>
|
|
534 Followed by a list of registers, it rummages through the STASH until it
|
|
535 finds the most recent saved values of these registers, and restores them.
|
|
536 These values are removed from the STASH, which effectively acts like a stack
|
|
537 (yet another normal programming concept which has managed to creep into
|
|
538 INTERCAL, sigh). After RETRIEVE, the register's value, BELONGS TO relation,
|
|
539 overloading, and IGNORE/REMEMBER state are restored as they were before the
|
|
540 corresponding STASH.
|
|
541 </P>
|
|
542
|
|
543 <P>
|
|
544 For example, the following program leaves <CODE>.1</CODE>, <CODE>;1</CODE> and
|
|
545 <CODE>,1 SUB #1</CODE> unchanged:
|
|
546 <PRE>
|
|
547 PLEASE STASH .1 + ;1
|
|
548 DO .1 <- ,1 SUB #1
|
|
549 DO STASH .1
|
|
550 DO ,1 SUB #1 <- #0
|
|
551 DO ;1 SUB .1 <- #1
|
|
552 ...
|
|
553 PLEASE RETRIEVE .1
|
|
554 DO ,1 SUB #1 <- .1
|
|
555 DO RETRIEVE .1 + ;1
|
|
556 </PRE>
|
|
557 </P>
|
|
558
|
|
559 <P>
|
|
560 Quantum version of STASH and RETRIEVE are of course available, by appending
|
|
561 "WHILE NOT STASHING THEM" or "WHILE NOT RETRIEVING THEM".
|
|
562 </P>
|
|
563
|
|
564 <H2><A NAME="give_up">GIVE UP</A></H2>
|
|
565
|
|
566 <P>
|
|
567 Finishes executing the program, presumably returning to saner things like a
|
|
568 shell or perhaps JCL.
|
|
569 </P>
|
|
570
|
|
571 <P>
|
|
572 ABSTAIN FROM and REINSTATE do not have any effect on GIVE UP. This means that
|
|
573 you can always GIVE UP, no matter how badly you've managed to screw up your
|
|
574 program. Also, it means that DON'T GIVE UP is guaranteed to be a no-op.
|
|
575 </P>
|
|
576
|
|
577 <P>
|
|
578 The quantum version of GIVE UP appends "WHILE CONTINUING TO RUN"
|
|
579 to the statement. What happens is that the program continues
|
|
580 to run, the fact it also stops at the same time is irrelevant
|
|
581 because it is not observable.
|
|
582 </P>
|
|
583
|
|
584 <P>
|
|
585 An interesting side-effect of the Quantum version is that if you
|
|
586 ABSTAIN FROM QUANTUM COMPUTING and then GIVE UP WHILE CONTINUING
|
|
587 TO RUN, you effectively GIVE UP; however if you REINSTATE QUANTUM
|
|
588 COMPUTING then the above Quantum GIVE UP is a no-op. In other
|
|
589 words, you can abstain from giving up, using this trick, by
|
|
590 calling it REINSTATE QUANTUM COMPUTING.
|
|
591 </P>
|
|
592
|
|
593 <H2><A NAME="read_out">READ OUT</A></H2>
|
|
594
|
|
595 <P>
|
|
596 Followed by a register list (arrays can be with or without subscripts),
|
|
597 will read the contents of the register to the standard output. See
|
|
598 <A HREF="input_output.html">the chapter on Input/Output</A>.
|
|
599 </P>
|
|
600
|
|
601 <P>
|
|
602 There is no Quantum READ OUT. Either you do it, or you don't.
|
|
603 </P>
|
|
604
|
|
605 <H2><A NAME="write_in">WRITE IN</A></H2>
|
|
606
|
|
607 <P>
|
|
608 Followed by a register list (arrays can be with or without subscripts),
|
|
609 will write into the register from the standard input. See
|
|
610 <A HREF="input_output.html">the chapter on Input/Output</A>.
|
|
611 </P>
|
|
612
|
|
613 <P>
|
|
614 The quantum WRITE IN (which appends "WHILE NOT WRITING THEM" to
|
|
615 the statement) always consumes some input, except that it assigns
|
|
616 it to variables while at the same time not assigning it. This is
|
|
617 not the same as executing the WRITE IN while not executing it,
|
|
618 which would require the input to be consumed while at the same
|
|
619 time not being consumed, which would be impossible as the internal
|
|
620 quantum state could be observed.
|
|
621 </P>
|
|
622
|
|
623 <H2><A NAME="enslave">ENSLAVE</A></H2>
|
|
624
|
|
625 <P>
|
|
626 Followed by two registers (without subscripts, if arrays), using the form:
|
|
627 <PRE>
|
|
628 DO ENSLAVE .1 TO ,1
|
|
629 </PRE>
|
|
630 it sets the BELONGS TO relation between the first and the second. It is
|
|
631 not an error if the first register is already a slave, although it can
|
|
632 be confusing. See <A HREF="belongs.html">the chapter on Belongs TO</A>.
|
|
633 </P>
|
|
634
|
|
635 <P>
|
|
636 The Quantum version of this statement appends "WHILE LEAVING IT FREE"
|
|
637 </P>
|
|
638
|
|
639 <H2><A NAME="free">FREE</A></H2>
|
|
640
|
|
641 <P>
|
|
642 Followed by two registers (without subscripts, if arrays), using the form:
|
|
643 <PRE>
|
|
644 DO FREE .1 FROM ,1
|
|
645 </PRE>
|
|
646 it removes the BELONGS TO relation between the first and the second. It is
|
|
647 an error if the first register was not a slave of the second. If the first
|
|
648 register BELONGed TO more than one register, the other owners remain
|
|
649 unchnanged. See <A HREF="belongs.html">the chapter on Belongs TO</A>.
|
|
650 </P>
|
|
651
|
|
652 <P>
|
|
653 The Quantum version of this statement appends "WHILE LEAVING IT IN SLAVERY"
|
|
654 </P>
|
|
655
|
|
656 <H2><A NAME="study">STUDY</A></H2>
|
|
657
|
|
658 <P>
|
|
659 Followed by a subject number, a lecture label, and a class name, using a
|
|
660 format like:
|
|
661 <PRE>
|
|
662 DO STUDY #2 AT (1030) IN CLASS @4
|
|
663 </PRE>
|
|
664 It advertise that the lecture is available. See
|
|
665 <A HREF="lectures.html">the chapter on Classes and Lectures</A>.
|
|
666 </P>
|
|
667
|
|
668 <P>
|
|
669 Beginning with CLC-INTERCAL 0.05, the subject number and the label can
|
|
670 be replaced by expressions.
|
|
671 </P>
|
|
672
|
|
673 <P>
|
|
674 The Quantum version of this statement appends "WHILE NOT STUDYING IT"
|
|
675 </P>
|
|
676
|
|
677 <H2><A NAME="enrol">ENROL</A></H2>
|
|
678
|
|
679 <P>
|
|
680 Followed by a register (without subscripts, if an array) and a list of
|
|
681 subjects, using a format like:
|
|
682 <PRE>
|
|
683 DO ENROL .2 TO LEARN #1 + #4 + #5
|
|
684 </PRE>
|
|
685 </P>
|
|
686
|
|
687 <P>
|
|
688 It looks for a class where these subjects are taught, and makes a note that
|
|
689 the register is not a student there. It is an error if no class is found
|
|
690 which teaches these subjects, or if there is more than one eligible class.
|
|
691 The latter case results in a CLASS WAR error. See
|
|
692 <A HREF="lectures.html">the chapter on Classes and Lectures</A>.
|
|
693 </P>
|
|
694
|
|
695 <P>
|
|
696 Beginning with CLC-INTERCAL 0.05, the subject numbers can be specified
|
|
697 as expressions and need not be constant.
|
|
698 </P>
|
|
699
|
|
700 <P>
|
|
701 The Quantum version of this statement appends "WHILE NOT ENROLLING"
|
|
702 </P>
|
|
703
|
|
704 <H2><A NAME="learns">LEARNS</A></H2>
|
|
705
|
|
706 <P>
|
|
707 Preceded by a register (without subscripts, if an array) and followed by
|
|
708 a subject number, as in:
|
|
709 <PRE>
|
|
710 DO .2 LEARNS #4
|
|
711 </PRE>
|
|
712 </P>
|
|
713
|
|
714 <P>
|
|
715 The register must have ENROLled in a class which teaches that subject. The
|
|
716 effect is to go to the lecture. The class will be temporarily ENSLAVed to
|
|
717 the register. This can be used to replace what other languages call "self"
|
|
718 or "this". See
|
|
719 <A HREF="lectures.html">the chapter on Classes and Lectures</A>.
|
|
720 </P>
|
|
721
|
|
722 <P>
|
|
723 Beginning with CLC-INTERCAL 0.05, the subject number can be specified
|
|
724 as an expression.
|
|
725 </P>
|
|
726
|
|
727 <P>
|
|
728 The Quantum version of this statement is specified with "WHILE NOT LEARNING IT"
|
|
729 </P>
|
|
730
|
|
731 <H2><A NAME="finish_lecture">FINISH LECTURE</A></H2>
|
|
732
|
|
733 <P>
|
|
734 Used in lectures to return to the statement following the last LEARNS. See
|
|
735 <A HREF="lectures.html">the chapter on Classes and Lectures</A>.
|
|
736 </P>
|
|
737
|
|
738 <P>
|
|
739 The Quantum version of this statement is specified with "WHILE CONTINUING IT"
|
|
740 </P>
|
|
741
|
|
742 <H2><A NAME="graduates">GRADUATES</A></H2>
|
|
743
|
|
744 <P>
|
|
745 Preceded by a register (if an array, without subscripts), it removes it
|
|
746 from the list of students of all classes. The effect is that the register
|
|
747 cannot LEARN anything after that, unless he ENROLs again. See
|
|
748 <A HREF="lectures.html">the chapter on Classes and Lectures</A>.
|
|
749 </P>
|
|
750
|
|
751 <P>
|
|
752 The Quantum version of this statement is specified with "WHILE REMAINING A STUDENT"
|
|
753 </P>
|
|
754
|
|
755 <H2><A NAME="convert">CONVERT</A></H2>
|
|
756
|
|
757 <P>
|
|
758 Followed by one statement template, the keyword "TO", and another statement
|
|
759 template. At runtime, the meaning of the first statement is changed into
|
|
760 the meaning of the second. In most back ends, this will be implemented by
|
|
761 keeping a list of code refences (or pointer to functions or whatever),
|
|
762 and changing them as needed. The statements must be "compatible", i.e.
|
|
763 their syntactic definition must use the same terminals. For example,
|
|
764 the statement ABSTAIN FROM can contain wither a single LABEL or a
|
|
765 GERUND LIST. In the latter form, can only be converted to a REINSTATE.
|
|
766 In the form with LABEL, it can be converted to COME FROM, NEXT, or REINSTATE.
|
|
767 The statements to do all these conversions are:
|
|
768 <PRE>
|
|
769 DO CONVERT ABSTAIN FROM GERUND LIST TO REINSTATE GERUND LIST
|
|
770 DO CONVERT ABSTAIN FROM LABEL TO COME FROM LABEL
|
|
771 DO CONVERT ABSTAIN FROM LABEL TO LABEL NEXT
|
|
772 DO CONVERT ABSTAIN FROM LABEL TO REINSTATE LABEL
|
|
773 </PRE>
|
|
774 </P>
|
|
775
|
|
776 <P>
|
|
777 There is a quantum version of this statement, obtained adding the
|
|
778 string "WHILE LEAVING IT UNCHANGED" at the end. This has the effect
|
|
779 of doing the conversion but at the same time not doing it.
|
|
780 This is described in more detail in <A HREF="quantum.html">the
|
|
781 chapter about Quantum INTERCAL</A>.
|
|
782 </P>
|
|
783
|
|
784 <P>
|
|
785 This statement was introduced in CLC-INTERCAL 0.05.
|
|
786 </P>
|
|
787
|
|
788 <H2><A NAME="swap">SWAP</A></H2>
|
|
789
|
|
790 <P>
|
|
791 Followed by one statement template, the keyword "AND", and another statement
|
|
792 template. At runtime, the meaning of the first statement is changed into
|
|
793 the meaning of the second, and vice versa. In most back ends, this will
|
|
794 be implemented by keeping a list of code refences (or pointer to functions
|
|
795 or whatever), and changing them as needed. The statements must be
|
|
796 "compatible", i.e. their syntactic definition must use the same terminals.
|
|
797 For example, "CALCULATE" has two terminals, a REGISTER and an EXPRESSION.
|
|
798 The other statement which has the same terminals is LEARNS. Therefore, they
|
|
799 can be swapped. The two following statements both do the same (and undo
|
|
800 each other):
|
|
801 <PRE>
|
|
802 DO SWAP REGISTER <- EXPRESSION AND REGISTER LEARNS EXPRESSION
|
|
803 DO SWAP REGISTER LEARNS EXPRESSION AND REGISTER <- EXPRESSION
|
|
804 </PRE>
|
|
805 </P>
|
|
806
|
|
807 <P>
|
|
808 There is a quantum version of this statement, obtained adding the
|
|
809 string "WHILE LEAVING THEM UNCHANGED" at the end. This has the effect
|
|
810 of doing the swapping but at the same time not doing it.
|
|
811 This is described in more detail in <A HREF="quantum.html">the
|
|
812 chapter about Quantum INTERCAL</A>.
|
|
813 </P>
|
|
814
|
|
815 <P>
|
|
816 This statement was introduced in CLC-INTERCAL 0.05
|
|
817 </P>
|
|
818
|
|
819 <H2><A NAME="create">CREATE</A></H2>
|
|
820
|
|
821 <P>
|
|
822 This is the most powerful statement of CLC-INTERCAL, and, by necessity, the
|
|
823 most complex. The syntax is described in detail in <A HREF="parsers.html">the
|
|
824 chapter about parsers</A>. It extends the C-unlike postprocessor (see the
|
|
825 <A HREF="#convert">convert</A> and <A HREF="#swap">swap</A> statements) in
|
|
826 such a way that a complete compiler can be written out of <CODE>CREATE</CODE>
|
|
827 statements. In fact, CLC-INTERCAL 1.-94 and newer are written this way.
|
|
828 </P>
|
|
829
|
|
830 <P>
|
|
831 This statement was introduced in CLC-INTERCAL 1.-94.
|
|
832 </P>
|
|
833
|
|
834 <P>
|
|
835 The Quantum version of this statement appends "WHILE NOT CREATING IT"
|
|
836 </P>
|
|
837
|
|
838 <H2><A NAME="destroy">DESTROY</A></H2>
|
|
839
|
|
840 <P>
|
|
841 This statement undoes the effect of a CREATE. Note that since
|
|
842 the compiler itself is just a big list of CREATE statement you
|
|
843 can also remove bits of the compiler you don't like. The syntax
|
|
844 is described in detail in <A HREF="parsers.html">the chapter
|
|
845 about parsers</A>.
|
|
846 </P>
|
|
847
|
|
848 <P>
|
|
849 This statement was introduced in CLC-INTERCAL 1.-94.
|
|
850 </P>
|
|
851
|
|
852 <P>
|
|
853 The Quantum version of this statement appends "WHILE NOT DESTROYING IT"
|
|
854 </P>
|
|
855
|
|
856 <H2><A NAME="while">WHILE</A></H2>
|
|
857
|
|
858 <P>
|
|
859 Preceded by a statement, and followed by another one, executes the two
|
|
860 simultaneously. The first statement acts as a "loop control" for the
|
|
861 second, which is repeated as many times as needed. For example:
|
|
862 <PRE>
|
|
863 PLEASE STUDY #1 AT (1000) IN CLASS @1
|
|
864 DO ENROL .1 TO LEARN #1
|
|
865 DO .1 LEARNS #1 WHILE READ OUT .1
|
|
866 </PRE>
|
|
867 </P>
|
|
868
|
|
869 <P>
|
|
870 Would keep reading out the value of .1 until the lecture is finished. This
|
|
871 might or might not cause disruption to the lecture.
|
|
872 </P>
|
|
873
|
|
874 <P>
|
|
875 The first statement can be replaced by an expression, in which case the
|
|
876 WHILE statement is called "event statement". If the expression can be
|
|
877 evaluated, the statement is executed and the program continues as normal.
|
|
878 If the expression produces an error, the WHILE is kept in suspended animation
|
|
879 until it is possible to execute it. For example:
|
|
880 <PRE>
|
|
881 DO ,1 <- #2
|
|
882 PLEASE DO ,1 SUB #1 #1 WHILE ,1 SUB #1 #1 <- #5
|
|
883 DO ,1 SUB #1 <- #2
|
|
884 DO ,1 <- #2 BY #2
|
|
885 DO .1 <- ,1 SUB #1 #1
|
|
886 DO READ OUT .1
|
|
887 </PRE>
|
|
888 </P>
|
|
889
|
|
890 <P>
|
|
891 Will read "V". This is because the ",1 SUB #1 #1" produces an error (too
|
|
892 many subscripts), but is retried as soon as ,1 is redimensioned, and causes
|
|
893 #5 to be assigned to ",1 SUB #1 #1" after dimensioning but before assigning
|
|
894 to .1
|
|
895 </P>
|
|
896
|
|
897 <P>
|
|
898 This statement was introduced in CLC-INTERCAL 0.05.
|
|
899 </P>
|
|
900
|
|
901 <P>
|
|
902 Note that there isn't a Quantum version of this statement, although
|
|
903 its two sub-statements can be quantum, for example:
|
|
904 <PRE>
|
|
905 DO ABSTAIN FROM (1) WHILE REINSTATING IT
|
|
906 WHILE
|
|
907 COME FROM (2) WHILE NOT COMING FROM THERE
|
|
908 </PRE>
|
|
909 </P>
|
|
910
|
|
911 <H2><A NAME="steal">STEAL and SMUGGLE</A></H2>
|
|
912
|
|
913 <P>
|
|
914 This statement is only available when the internet option is
|
|
915 in force. Since CLC-INTERCAL 1.-94.-2 this also requires the
|
|
916 optional package CLC-INTERCAL-INET to be installed.
|
|
917 </P>
|
|
918
|
|
919 <P>
|
|
920 The statement is followed by a list of variables,
|
|
921 optionally ON and a Process ID and optionally FROM and an IP
|
|
922 address. For example:
|
|
923 <PRE>
|
|
924 DO STEAL .1 ON #1234 FROM :1
|
|
925 DO STEAL .1 ON #1234
|
|
926 DO STEAL .1 FROM :1
|
|
927 DO STEAL .1
|
|
928 </PRE>
|
|
929 </P>
|
|
930
|
|
931 <P>
|
|
932 The first statement connects to a computer with IP address :1
|
|
933 (a 32 bit number interpreted as an IP address), and locates the
|
|
934 INTERCAL program with Process ID #1234. If that can be found, its
|
|
935 .1 variable is stolen (see below). The second statement is similar,
|
|
936 but it connects to a random IP address obtained by broadcasting
|
|
937 on the local network. The third statement specifies an IP address
|
|
938 but not a Process ID: the remote computer is asked to provide
|
|
939 a random one. Finally, the last statement broadcasts for an IP
|
|
940 address, then asks the computer to select a random process.
|
|
941 </P>
|
|
942
|
|
943 <P>
|
|
944 Stealing a variable means doing a destructive copy, so that the
|
|
945 vistim can no longer use it, while the thief gets the original
|
|
946 value. For example, suppose the following program runs on Process
|
|
947 ID #666 on IP address 10.0.0.1:
|
|
948 <PRE>
|
|
949 DO .1 <- #2
|
|
950 (2) PLEASE COME FROM (.1)
|
|
951 DO READ OUT .1
|
|
952 DO GIVE UP
|
|
953 </PRE>
|
|
954 (by the way, the second statement is recognised by the optimiser,
|
|
955 which will cause the program to wait for a network connection
|
|
956 instead of performing a busy wait, so this program will use very
|
|
957 little CPU time).
|
|
958 </P>
|
|
959
|
|
960 <P>
|
|
961 Now consider the following program running on some other computer:
|
|
962 <PRE>
|
|
963 DO STEAL .1 ON #666 FROM #12288 ¢ #1
|
|
964 PLEASE READ OUT .1
|
|
965 DO GIVE UP
|
|
966 </PRE>
|
|
967 </P>
|
|
968
|
|
969 <P>
|
|
970 This produces "II", because it goes to get the variable .1 from
|
|
971 the previous program (#12288 ¢ #1 is 10.0.0.1; do the calculation
|
|
972 if you don't believe me).
|
|
973 </P>
|
|
974
|
|
975 <P>
|
|
976 Meanwhile, the first program produces NIHIL and terminates: this
|
|
977 is because variable .1 has been stolen, so it's now reset to its
|
|
978 initial value (#0). This causes the COME FROM to stop executing,
|
|
979 and the READ OUT to produce NIHIL.
|
|
980 </P>
|
|
981
|
|
982 <P>
|
|
983 If a register is IGNOREd by the victim it cannot be stolen. This
|
|
984 is because stealing a register modifies it. However, the SMUGGLE
|
|
985 statement, which has identical syntax, allows to copy an IGNOREd
|
|
986 register, of course without modifying it. It is a runtime error to
|
|
987 STEAL an IGNOREd register, or to SMUGGLE one which is not IGNOREd.
|
|
988 </P>
|
|
989
|
|
990 <P>
|
|
991 Note that the thief is free to IGNORE or REMEMBER a register
|
|
992 before stealing or smuggling it: the theft will always succeed,
|
|
993 but the subsequent assignment of the value to the thief's variables
|
|
994 is controlled by the thief's IGNORE state for the register.
|
|
995 </P>
|
|
996
|
|
997 <P>
|
|
998 STEAL and SMUGGLE have Quantum counterparts, which are specified
|
|
999 with "WHILE NOT STEALING IT" and "WHILE NOT SMUGGLING IT". Like
|
|
1000 Quantum WRITE IN, the theft always happens, but the assignment
|
|
1001 of the result happens while not happening.
|
|
1002 </P>
|
|
1003
|
|
1004 <P>
|
|
1005 The next section suggests a way to obtain IP addresses and process IDs
|
|
1006 </P>
|
|
1007
|
|
1008 <H2><A NAME="case">CASE</A></H2>
|
|
1009
|
|
1010 <P>
|
|
1011 This statement is only available if the internet option is in
|
|
1012 effect. Followed by an expression, IN and a list of case elements
|
|
1013 (with the form variable THEN statement), executes a generic network
|
|
1014 look-up and assigns the results to the variables indicated in
|
|
1015 the case elements; after that, it executes all the statements in
|
|
1016 sequence. If there are multiple case elements, they are separated
|
|
1017 by the keyword OR.
|
|
1018 </P>
|
|
1019
|
|
1020 <P>
|
|
1021 The network look-up performed depends on the type of the
|
|
1022 expression. If it is an array, it is converted to characters (as
|
|
1023 if you READ it OUT) and used as a name to perform a DNS look-up;
|
|
1024 if it is a number, it is interpreted as an IP address; if it
|
|
1025 happens to be a broadcast address, the corresponding broadcast
|
|
1026 is executed to return a list of IP addresses of computers running
|
|
1027 INTERCAL programs; if it is a unicast address, the corresponding
|
|
1028 computer is queried for the list of Process IDs running on it
|
|
1029 (only Process IDs of INTERCAL programs with the internet option
|
|
1030 are returned by this query).
|
|
1031 </P>
|
|
1032
|
|
1033 <P>
|
|
1034 A network look-up returns a list of values: in the DNS or broadcast
|
|
1035 case, a list of IP addresses, in the unicase case, a list of
|
|
1036 process IDs. The list elements are assigned to the registers
|
|
1037 specified in the case elements. If there are more elements than
|
|
1038 registers, a random selection is used; if there are more registers
|
|
1039 than elements, the elements are duplicated to get the right number.
|
|
1040 </P>
|
|
1041
|
|
1042 <P>
|
|
1043 Consider the statement:
|
|
1044 <PRE>
|
|
1045 DO CASE #0 IN
|
|
1046 :1 THEN CASE :1 IN
|
|
1047 .1 THEN STEAL ,1 ON .1 FROM :1
|
|
1048 </PRE>
|
|
1049 </P>
|
|
1050
|
|
1051 <P>
|
|
1052 This is the internal implementation of DO STEAL ,1 - first,
|
|
1053 it broadcasts on all local network interfaces to get a list of
|
|
1054 IP addresses (#0 is considered a broadcast address by the CASE
|
|
1055 statement). Then a random one is selected (because there is only
|
|
1056 one case element) and assigned to :1. Then the statement inside
|
|
1057 the CASE is executed - this is another CASE, his time using the
|
|
1058 IP address returned by the first one to get a list of Process
|
|
1059 IDs. Again, there is only one element, so a random one is selected
|
|
1060 and assigned to .1 - finally, the STEAL statement uses the IP
|
|
1061 address and Process ID. The only real difference between this
|
|
1062 example and a simple DO STEAL .1 is that this example also keeps
|
|
1063 the random IP and PId used, which may be used by the program to
|
|
1064 do something else, while the implicit CASE executed by STEAL when
|
|
1065 ON or FROM are not specified does not save these numbers.
|
|
1066 </P>
|
|
1067
|
|
1068 <P>
|
|
1069 It goes without saying that there is a Quantum CASE statement;
|
|
1070 the syntax is slightly unusual: DO CASE expression WHILE NOT
|
|
1071 CASING IT IN register THEN statement OR register THEN statement
|
|
1072 </P>
|
|
1073
|
|
1074 <P>
|
|
1075 To improve the program's legibility when a CASE statement is
|
|
1076 nested inside another, it is possible to terminate the list of
|
|
1077 case elements with the keyword ESAC. This closes the innermost
|
|
1078 CASE. For example:
|
|
1079 <PRE>
|
|
1080 DO CASE #0 IN
|
|
1081 :1 THEN CASE :1 IN
|
|
1082 .1 THEN STEAL ,1 ON .1 FROM :1
|
|
1083 OR
|
|
1084 .2 THEN READ OUT .2
|
|
1085 ESAC
|
|
1086 OR
|
|
1087 :2 THEN WRITE IN :3
|
|
1088 ESAC
|
|
1089 </PRE>
|
|
1090 </P>
|
|
1091
|
|
1092 <P>
|
|
1093 (And, yes, it's a rather meaningless program, but it shows
|
|
1094 the syntax)
|
|
1095 </P>
|
|
1096
|
|
1097 </BODY>
|
|
1098 </HTML>
|
|
1099
|