Christian Collberg
Department of Computer Science
University of Arizona
(* (+ 5 6) 7)
|
|
b := 2; c := b;both b and c would hold the value 2. In Clu, b and c would both point to the same object, which contains the value 2.
int i,j; String s,t; if (i==j) ... if (s==t) ...can be confusing for novel programmers.
b-c+dis reordered as
b+d-cthen an overflow can occur if b+d doesn't fit in an int.
(a+b)+cmight evaluate to 0 (due to a loss of information), while
a+(b+c)would evaluate to a.
if (x<>0) and (y/x > 5) then
4 > 8 or 11 < 3
is parsed as
4 > (8 or 11) < 3
Hence, it becomes necessary to insert parenthesis.
begin x := if b<c then d else e; y := begin f(b); g(c) end; z := while b<c do g(c) end; 2+3 endThis compound block returns 5.
IF a .LT. B GOTO 10
...
GOTO 20
10: ...
20:
This is an if-then-else-statement.
|
24#24 |
25#25 |
26#26
28#28
29#29
GOTO (15, 20, 30) I
15: ...
20: ...
30: ...
If I=1, we'll jump to 15; if I=2, we'll
jump to 20; if it's 3, we'll jump to 30, otherwise
we'll do nothing.
30#30
33#33
34#34
35#35
LOOP .... IF ... THEN EXIT; .... END
for i := 1, 2, 5, 7, 9 do ... for i := 1 step 2 until 10 do ... for i := i, i + 2 while i < 10 do ...
38#38
(define (fact n)
(if (= n 1)
1
(* n (fact (- n 1)))))
(define (fact-cps n C)
(if (= n 1)
(C 1)
(fact-cps (- n 1) (
lambda(v) (C (* n v))))))
(fact-cps 5 (lambda(v) (display v)))