Languages
Algol-68 | C | Pascal | Turing | |
---|---|---|---|---|
general | block structured, expression based language | "flat", some expression based features | block structured, imperative | imperative, has `modules' |
expressions | ||||
arith | +,-,*,/,^ NB.% is int div |
+,-,*,/,% NB.% is int mod |
+,-,*,/, div, mod | +,-,*,/, ** |
comparisons | =, <>, <, <=, >, >= | ==, !=, <, <=, >, >= | =, <>, <, <=, >, >= | =, not= <, <=, >, >= |
logical | and, or, not | &&, ||, ! | and, or, not | and, or, not |
conditional expression | if e then e1 [elsf e' then e2] else e3 fi or (e | e1 | e2) also case exp'n |
e ? e1 : e2 | n.a. | n.a. |
statements | ||||
assignment | x:=e | x=e; | x:=e | x:=e |
conditional | if e then s1 [elsf e' then s2] [else s3] fi |
if(e) s1 [else s2] |
if e then s1 [else s2] |
if e then s1 [elsf e' then s2] [else s3] end if |
case | case e in s1,s2,... out s esac | switch(e) {case e1:s1 ...} | case e of e1:s1;... end | case e of label e1:s1;... end case |
for | [for] [i] [from e1] [by e2] [to e3] [while eb] do ... od | for(s1;eb;s2)s3 | for i:=e1 (to | downto) e2 do s | for [decreasing] i:range s end for |
while | see above | while( ) | while do | loop ... exit when e; ... end loop |
repeat | n.a. | n.a. | repeat until e | use loop |
group | begin...end or (...) | {...} | begin...end | begin...end |
function result | final exp'n | return e | fnName=e | result e |
declarations | ||||
constants | T c=e | #define | const c=ce | const c:=e |
variables | T x [=e] | T x | var x:T | var x:T |
subroutine | proc( )void s | void p( ) {...} | procedure p(...) ... begin ... end | procedure p(...) ... end |
function | proc(...)T e | T f(...) {...} | function f(...)T ... begin ... end | function f(...)T ...end |
function result | final exp'n | return e | fnName=e | result e |
parameters | T x | T x | [var] x:T | [var] x:T |
types | © L.Allison '99 | |||
data type | mode | typedef | type | type |
basic types | int real bool char | int float char | integer real boolean char | int real boolean char |
structure | struct( ) | struct( ) | record end | record end record |
field access | f of s | s.f | s.f | s.f |
pointer | ref | * | ^ | pointer to |
pointer access | implicit or cast | *, -> ptr & field |
^ | thecollection(x) |
special ptr value | nil | NULL | nil | nil(thecollection) |
union | union(...) | union | record case variant | union ... end union |
array | array T1 of T2 | T2 a[size] | array [T1] of T2 | array T1 of T2 |
array access | a[i] | a[i] | a[i] | a(i) |
array slicing | m[i:j, ] rows i to j of 2D | n.a. | m[i] is row i of 2d | n.a. |
sets | n.a. | n.a. (use bits) | set of T | set of T |