, | C, C++, Go, JavaScript, Matlab, Perl, Pike, Prolog, Scilab |
. | Smalltalk |
; | Ada, Awk, B, Beta, BourneShell, C, C#, C++, E, F#, FishShell, GNU-sed, Go, Haskell, Io, Java, JavaScript, Maple, Mathematica, Matlab, merd, Modula-3, OCaml, Pascal, Perl, Perl6, PHP, Pike, PL/I, Pliant, Python, Ruby, SML, Tcl, YCP |
: | Maple |
nothing, optionally ; | Classic REXX, Lua |
space | Eiffel, Rebol |
end-of-line | Assembler, Awk, Basic, BourneShell, CoffeeScript, E, F#, FishShell, Fortran, GNU-sed, Haskell, Io, JavaScript, Lua, Matlab, merd, Pliant, Python, Ruby, Tcl |
(begin ...) | Scheme |
(progn ...) (prog1 ...) (prog2 ...) | Common Lisp, Emacs Lisp |
>> | Haskell |
if c then ... | CoffeeScript, F#, merd, OCaml, Pascal, Tcl |
if c then ... end | Eiffel, Lua, Oz, Ruby |
if c then ... end if | Ada, Maple |
if c then ... fi | Maple |
if c; then ... fi | BourneShell |
if (c) then ... end | Dylan |
if c do ... | BCPL |
IF c THEN ... END | Modula-2, Modula-3 |
if (c) ... | Awk, B, C, C#, C++, Java, JavaScript, PHP, Pike, YCP |
if c: ... | Python |
if c ... | Pliant, Rebol, Tcl |
if (c): ... endif | PHP |
if c {...} | Go, Perl6 |
if c [...] | Logo |
if (c) {...} | E, Perl, Yorick |
IF c ... | MUMPS |
c -> ... | FL |
c ... if | PostScript |
... if c | Perl, Ruby |
c if b1 then | Forth |
(if c ...) | Common Lisp, Scheme |
(when c ...) | Emacs Lisp |
c and ... | Perl, Ruby |
if(c, ...) | Io |
If[c, ...] | Mathematica |
if(c) then(...) | Io |
c ifTrue(...) | Io |
c ifTrue: ... | Smalltalk |
<xsl:if test="c">...</xsl:if> | XSLT |
if c ... endif | Vimscript |
If c Then ... | Visual Basic |
If c ... End If | Visual Basic |
if c; ... end | Ruby |
if c; ...; end | FishShell |
if c, ..., end | Matlab |
if c ... end | Matlab, Ruby |
if c then ; ... if c then ... if c then do ... end | Classic REXX |
c and ... | Perl |
t label | GNU-sed |
if c ... | CoffeeScript |
if c then b1 else b2 | CoffeeScript, F#, Haskell, merd, OCaml, SML |
if c then b1 else b2 end | Eiffel, Lua, Ruby |
if c then b1 elsif c2 then b2 else b3 end if | Ada |
if c then b1 elseif c2 then b2 else b3 end | Eiffel, Oz |
if (c) then b1 elseif (c2) then b2 else b3 end | Dylan |
IF c THEN b1 ELSIF c2 THEN b2 ELSE b3 END | Modula-3 |
If c Then b1 ElseIf c2 Then b2 Else b3 End If | Modula-2 |
if (c) b1 else b2 | Awk, B, C, C#, C++, Java, JavaScript, Pike, YCP |
if c b1 elsif c2 b2 b3 | Tcl |
if c then b1 elseif c2 then b2 else b3 | Tcl |
if c then begin b1 end else begin b2 end | Pascal |
if c b1 eif c2 b2 else b3 | Pliant |
if c then b1 elif c2 then b2 else b3 end if | Maple |
if c; then b1; elif c2; then b2; else b3; fi | BourneShell |
if c; b1; else b2; end | FishShell |
if c1, b1, elseif c2, b2, else, b3, end | Matlab |
if (c) b1 elseif (c2) b2 else b3 | PHP |
if (c): b1 elseif (c2): b2 else: b3 endif | PHP |
if (c) {b1} elsif (c2) {b2} else {b3} | Perl |
if (c) {b1} else {b2} | E, Yorick |
(if c b1 b2) | Common Lisp, Scheme |
(if c then b1 else b2) | Mercury |
(c -> b1 ; c2 -> b2 ; b3) | Mercury |
c -> b1 ; b2 | FL |
if(c, b1, b2) | Io |
If[c, b1, b2] | Mathematica |
if(c) then(b1) else(b2) | Io |
c ifTrue: b1 ifFalse: b2 | Smalltalk |
ifelse c [b1] [b2] | Logo |
shunt c b1 c2 b2 b3 | Pliant |
either c b1 b2 / if/else c b1 b2 | Rebol |
(cond (c b1) (c2 b2) (t b3)) | Common Lisp, Emacs Lisp |
(cond (c b1) (c2 b2) (else b3)) | Scheme |
Which[c, b1, c2, b2, True, b3] | Mathematica |
c -> b1 ; c2 -> b2 ; b3 | Prolog |
case when c; b1 when c2; b2 else b3 end | Ruby |
test c then b1 or b2 | BCPL |
e | c = b1 | c2 = b2 | otherwise = b3(1) | Haskell |
c b1 b2 ifelse | PostScript |
c if b1 else b2 then | Forth |
c ? b1 : b2 | Awk, B, C, C#, C++, Java, JavaScript, Perl, PHP, Ruby, Tcl, YCP, Yorick |
c ?? b1 !! b2 | Perl6 |
b1 if c else b2(2) | Python |
$SELECT(c:b1,c2:b2,1:b3) | MUMPS |
c -> b1, b2 | BCPL |
(if c then b1 else b2 fi) | Beta |
<xsl:choose> <xsl:when test="c"> b1 </xsl:when> <xsl:when test="c2"> b2 </xsl:when> <xsl:otherwise> b3 </xsl:otherwise> </xsl:choose> | XSLT |
if c1 ... elseif c2 ... else ... endif | Vimscript |
If c Then b1 Else b2 | Visual Basic |
If c b1 Else b2 End If | Visual Basic |
if c: b1 elif c2: b2 else: b3 | Python |
if c b1 elsif c2 b2 else b3 end | Ruby |
if c b1 elseif c2 b2 else b3 end | Matlab |
if c then ; b1 ; else ; b2 if c then b1 else b2 if c then do b1 ... end else do b2 ... end | Classic REXX |
IF c ... ELSE ... | MUMPS |
if c b1 else if c2 b2 else b3 | CoffeeScript |
if c {b1} else if c2 {b2} else {b3} | Go |
unless | CoffeeScript, Emacs Lisp, Perl |
ifFalse | Smalltalk |
if(c) not then(...) | Io |
switch (val) { case v1: ...; break; case v2: case v3: ...; break; default: ...; } | C, C++, Java, JavaScript, PHP, Pike |
switch val { case v1: ...; goto done; case v2: case v3: ...; goto done; } ...; done: | B |
switch (val) { case v1: ...; break; case v2: case v3: ...; break; default: ...; break; }(3) | C# |
switch (val) { match v1 { ... } match v2 { ... } match _ { ... } } | E |
switchon val case v1: ... case v2: ... default: ... | BCPL |
switch val case v1 ... case v2 v3 ... case '*' ... end | FishShell |
switch val case v1 ... case {v2,v3} ... otherwise ... end | Matlab |
case val of v1 : ...; v2, v3 : ... else ... end | Pascal |
switch val { v1 {...} v2 - v3 {...} default {...} } | Tcl |
case val in v1) statement1 ;; v2|v3) statement23 ;; *) statement_else ;; esac | BourneShell |
(if val // v1 then ... // v2 then ... else ... if) | Beta |
match val with | v1 -> ... | v2 | v3 -> ... | _ -> ... | F#, OCaml |
case val of v1 => ... | v2 => ... | _ => ... | SML |
CASE val OF v1 => ... | v2 => ... ELSE => ... END | Modula-3 |
case val of v1 -> ... v2 -> ... _ -> ... | Haskell |
val case v1 of ... endof v2 of ... endof ... endcase | Forth |
val. v1 -> ... v2 -> ... _ -> ... | merd |
(case val ((v1) ...) ((v2) ...) (otherwise ...)) | Common Lisp |
(case val ((v1) ...) ((v2) ...) (else ...)) | Scheme |
case val is when v1 => ... when v2 | v3 => ... when others => ... end case; | Ada |
case val when v1; ... when v2, v3; ... else ... end | Ruby |
inspect val when v1 then statement1 when v2, v3 => statement23 else statement_else end | Eiffel |
select (val); when (v1) statement1; when (v2, v3) statement23; otherwise statement_else; end; | PL/I |
X = val, (X = v1, ... ; X = v2, ... ; ...) | Mercury, Prolog |
my %case = ( v1 => sub { ... }, v2 => sub { ... }, ); if ($case{val}) { $case{val}->() } else { ... } | Perl |
use Switch; switch ($val) { case v1 { ... } case v2 { ... } else ... })(4) | Perl |
given $val { when v1 { ... } when v2 { ... } default { ... } } | Perl6 |
Select val Case v1 ... Case v2, v3 ... Case Else ... End Select | Visual Basic |
switch (val) { v1 { ... } v2 { ... } default { ... } } | MSH |
switch val [ v1 [...] v2 [...] ] switch/default [ v1 [...] v2 [...] ][...] | Rebol |
val caseOf: {[v1]->[...]. [v2]->[...]} otherwise: ... | Squeak |
Switch[val, v1, ..., v2, ..., _, ...] | Mathematica |
select when v1 ... when v2 | v3 ... otherwise ... end | Classic REXX |
CASE val WHEN v1 THEN ... WHEN v2 THEN ... ELSE ... END | SQL92 |
switch val { case v1, v2, ...: ... fallthrough case v3: ... default: ... } | Go |
forever loop
loop | CoffeeScript, merd, Perl6, PostScript, Ruby |
loop(...) | Io |
loop ... end loop | Ada |
LOOP ... END | Modula-3 |
(loop do ...) | Common Lisp |
cycle (# do ... #) | Beta |
repeat | Squeak |
begin ... again | Forth |
forever | Logo, Rebol |
Do ... Loop | Visual Basic |
do forever ... end | Classic REXX |
for {} | Go |
while condition do something
while (c) ... | Awk, B, C, C#, C++, E, Java, JavaScript, Perl, PHP, Pike, Ruby, YCP, Yorick |
while c ... | CoffeeScript, Perl6, Tcl |
while c loop ... end loop | Ada |
while c do ... | BCPL, Pascal, SML |
while c do ... done | F#, OCaml |
while c do ... end do | Maple |
while c do ... end | Lua |
WHILE c DO ... END | Modula-3 |
while c: ... | Python |
while c; do ...; done | BourneShell |
while c; ...; end | FishShell |
while c, ..., end | Matlab |
while [c][...] | Rebol |
while c [...] | Logo |
while(c, ...) | Io |
While[c, ...] | Mathematica |
do.while [...] c | Logo |
c whileTrue: ... | Smalltalk |
(loop while c do ...) | Common Lisp |
loop (# while ::< (# do c -> value #) do ... #) | Beta |
begin c while ... repeat | Forth |
from until not c loop ... end | Eiffel |
while c ... | Pliant |
while c do ... | F# |
Do While c ... Loop | Visual Basic |
while c ... endwhile | Vimscript |
do while c ... end | Classic REXX |
for c {...} | Go |
do something until condition
do ... until c | Perl6 |
do {...} until c | Perl |
do ... while (!c) | Awk, C, C#, C++, Java, JavaScript, Pike, Yorick |
begin ... end until c | Ruby |
begin ... c until | Forth |
REPEAT ... UNTIL c | Modula-3 |
loop (# until ::< (# do c -> value #) do ... #) | Beta |
loop ... exit when c; end loop | Ada |
(loop do ... until c) | Common Lisp |
... repeatuntil c | BCPL |
repeat ... until c | Lua, Pascal |
repeat ... until (c) | YCP |
repeat, ..., c | Prolog |
until [... c] | Rebol |
until c [...] | Logo |
do.while [...] c | Logo |
While[...; c] | Mathematica |
[...] whileFalse: [c] | Smalltalk |
Do ... Loop Until c | Visual Basic |
for each value in a numeric range, 1 increment (see also the entries about ranges)
for (int i = 1; i <= 10; i++) ... | C, C#, C++ |
for (i = 1; i <= 10; i++) ... | Awk, JavaScript |
for ($i = 1; $i <= 10; $i++) ... | PHP |
foreach my $i (1 .. 10) { ... } | Perl |
foreach ($i in 1..10) { ... } | MSH |
for (1 .. 10) -> $i { ... } | Perl6 |
for i = 1:10, ..., end | Matlab |
for i = 1, 10 do ... end | Lua |
for i := 1 to 10 do ... | Pascal |
for i = 1 to 10 do ... done | F#, OCaml |
For i = 1 To 10 ... Next | Visual Basic |
for i in 1 .. 10 loop ... end loop | Ada |
for i in 1 .. 10 do ... done | F# |
for i in [1..10] ... | CoffeeScript |
for i in xrange(1, 11) | Python |
for i in (seq 10); ...; end | FishShell |
FOR I=1:1:10 ... | MUMPS |
for i from 1 to 10 do ... end do | Maple |
for [i 1 10 +1] [...] | Logo |
for {set i 1} {$i <= 10} {incr i} {...} | Tcl |
1 1 10 ... for | PostScript |
11 1 do ... loop | Forth |
(1..10).each {|i| ... } | Ruby |
1.upto(10) {|i| ... } | Ruby |
1 to(10) foreach(...) | Io |
1 to: 10 do: [...] | Smalltalk |
(loop for i from 1 to 10 do ...) | Common Lisp |
do label i = 1, 10 | Fortran |
Do[..., {i, 1, 10}](5) | Mathematica |
do i = 1 for 10 ... end | Classic REXX |
for i := 1; i <= 10; i++ {...} | Go |
for each value in a numeric range, 1 decrement
for X := 10 downto 1 do ... | Pascal |
for i = 10 downto 1 do ... done | F#, OCaml |
for i in reverse 1 .. 10 loop ... end loop | Ada |
for i in 10 .. -1 .. 1 do ... done | F# |
for (int i = 10; i >= 1; i--) ... | C, C#, C++ |
for (my $i = 10; $i >= 1; $i--) { ... } | Perl |
loop (my $i = 10; $i >= 1; $i--) { ... } | Perl6 |
for (i = 10; i >= 1; i--) ... | Awk, JavaScript |
for ($i = 10; $i >= 1; $i--) ... | PHP |
from i := 10 until i < 1 loop ... i := i - 1 end | Eiffel |
for i = 10:-1:1, ..., end | Matlab |
for i = 10, 1, -1 do ... end | Lua |
For i = 10 To 1 Step -1 ... Next | Visual Basic |
for i in xrange(10, 0, -1) | Python |
for i in `seq 10 -1 1`; do ...; done | BourneShell |
for i in (seq 10 -1 1); ...; end | FishShell |
for i from 10 to 1 by -1 do ... end do | Maple |
for [i 1 10 -1] [...] | Logo |
FOR I=10:-1:1 ... | MUMPS |
for {set i 10} {$i >= 1} {incr i -1} {...} | Tcl |
10 -1 1 ... for | PostScript |
1 10 do ... -1 +loop | Forth |
1 to: 10 by: -1 do: [...] | Smalltalk |
10 to(1) foreach(...) | Io |
10.downto(1) {|i| ... } | Ruby |
(loop for i from 1 to 10 by -1 do ...) | Common Lisp |
do label i = 10, 1, -1 | Fortran |
Do[..., {i, 10, 1, -1}] | Mathematica |
do i = 10 to 1 by -1 ... end | Classic REXX |
for i in [10..1] ... | CoffeeScript |
for i := 10; i >= 1; i-- {...} | Go |
for each value in a numeric range, free increment
for (int i = 1; i <= 10; i += 2) ... | C, C#, C++, Pike |
for (i = 1; i <= 10; i += 2) ... | Awk, JavaScript |
for ($i = 1; $i <= 10; $i += 2) ... | PHP |
for (my $i = 1; $i <= 10; $i += 2) { ... } | Perl |
loop (my $i = 1; $i <= 10; $i += 2) { ... } | Perl6 |
from i := 1 until i > 10 loop ... i := i + 2 end | Eiffel |
for i = 1:3:10, ..., end | Matlab |
for i = 1, 10, 2 do ... end | Lua |
For i = 1 To 10 Step 2 ... Next | Visual Basic |
for i in 1 .. 2 .. 10 do ... done | F# |
for i in xrange(1, 11, 2) | Python |
for i in (seq 1 2 10); ...; end | FishShell |
for i from 1 to 10 by 2 do ... end do | Maple |
for [i 1 10 2] [...] | Logo |
FOR I=1:2:10 ... | MUMPS |
for {set i 0} {$i <= 10} {incr i 2} {...} | Tcl |
1 2 10 ... for | PostScript |
11 1 do ... 2 +loop | Forth |
1 to: 10 by: 2 do: [...] | Smalltalk |
(1..10).step(2) {|i| ... } | Ruby |
1 to (9,2) foreach(...) | Io |
(loop for i from 1 to 10 by 2 do ...) | Common Lisp |
do label i = 1, 10, 2 | Fortran |
Do[..., {i, 1, 10, 2}] | Mathematica |
do i = 1 to 10 by 2 ... end | Classic REXX |
for i in [1..10] by 2 ... | CoffeeScript |
for i := 1; i <= 10; i += 2 {...} | Go |
for "a la C" (while + initialisation)
for | Awk, C, C#, C++, Go, Java, JavaScript, Mathematica, MSH, Perl, PHP, Pike, Tcl, Yorick |
loop | Perl6 |
for ((x = 0; x < 10; x++)); do ...; done | BourneShell |
from init_code until c loop ... incr_statement end | Eiffel |
(loop with VAR = INITIAL-VALUE ... while CONDITION finally INCREMENT ...) | Common Lisp |
returning a value
return(6) | Ada, Awk, B, BCPL, BourneShell, C, C#, C++, Classic REXX, CoffeeScript, Common Lisp, E, FishShell, Go, Io, Java, JavaScript, Lua, Maple, Matlab, Perl, Perl6, PHP, Pike, Pliant, Python, Rebol, Ruby, Tcl, Vimscript, YCP, Yorick |
Return | Mathematica, Visual Basic |
RETURN | Modula-3 |
resultis(7) | BCPL |
return-from xxx | Common Lisp |
^ | Smalltalk |
Exit Function / Exit Sub | Visual Basic |
exit | Forth |
output | Logo |
goto (unconditional jump)
goto | Ada, B, Basic, BCPL, C, C#, C++, Cobol, Fortran, Go, Logo, MUMPS, Pascal, Perl, PHP5, Yorick |
Goto | Mathematica |
go throw | Common Lisp |
signal | Classic REXX |
b | GNU-sed |
b, bra, jmp | Assembler |
continue / break
continue / break | Awk, C, C#, C++, CoffeeScript, E, FishShell, Go, Io, Java, JavaScript, Matlab, PHP, Pike, Python, Tcl, YCP, Yorick |
Continue / Break | Mathematica |
next / last | Perl, Perl6 |
next / break(8) | Maple, Ruby |
/ break | BCPL, Lua |
/ break/return | Rebol |
/ exit | Ada, PostScript |
/ stop | Logo |
restart / leave | Beta, Pliant |
/ Exit Do, Exit For | Visual Basic |
/ return-from xxx or return | Common Lisp |
iterate / leave | Classic REXX |
/ leave | Forth |
redo / retry
redo/ | Perl, Perl6 |
redo / retry | Io, Ruby |
throwing
raise | Ada, Eiffel, F#, merd, OCaml, Python, Ruby, Scheme-SRFI34, SML |
RAISE | Modula-3 |
raise ... end | Oz |
Exception raise | Io |
throw | C#, C++, CoffeeScript, E, Erlang, Forth, Haskell, Java, JavaScript, Logo, PHP5, Pike, Prolog, Rebol |
Throw | Mathematica |
throw/name | Rebol |
die | Perl, Perl6 |
return -code | Tcl |
error | Common Lisp, Dylan, Emacs Lisp, Lua, Lua, Maple, Matlab, Pliant, Yorick |
signal | Common Lisp, Dylan, Smalltalk |
signal predefined_condition_name | Classic REXX |
cerror warn | Common Lisp |
[NSException raise:name ...] | Objective-C |
panic(v) | Go |
catching
try: a except exn: ... | Python |
try a with exn -> ... | F#, OCaml |
try a catch (exn) ... | C#, C++, Java, JavaScript |
try a ... catch exn ... | CoffeeScript |
try { ... } catch(t $v) { ... } | PHP5 |
try a catch exn then ... end | Oz |
try a catch exn: ... end try | Maple |
try(a) ; catch(...) | Io |
try { a CATCH exn { ... } } | Perl6 |
TRY a EXCEPT exn => ... END | Modula-3 |
a handle exn => ... | SML |
a on: exception_name do: [:exn | ...] | Smalltalk |
ifCurtailed | Smalltalk |
rescue | Eiffel, Ruby |
eval {a}; if ($@) ... | Perl |
exception when exception_name => | Ada |
catch a (\exn -> ...) | Haskell |
catch | Erlang, Forth, Logo, Prolog, Rebol, Tcl |
Catch | Mathematica |
catch/name | Rebol |
catch(...) or catch { ... }; | Pike |
if (catch(exn)) { ... } a | Yorick |
pcall | Lua |
with-exception-handler or guard | Scheme-SRFI34 |
block a exception(exn) ... end | Dylan |
?, shy, safe | Pliant |
handler-bind handler-case ignore-errors | Common Lisp |
NS_DURING a NS_HANDLER ... NS_ENDHANDLER | Objective-C |
try a catch ... end | Matlab |
signal on predefined_condition_name ... predefined_condition_name : ... | Classic REXX |
recover() | Go |
cleanup: code executed before leaving
ensure | Ruby, Smalltalk |
finally | C#, F#, Java, Maple, Python |
FINALLY | Modula-3 |
unwind-protect | Common Lisp, Emacs Lisp |
cleanup | Dylan |
dynamic-wind | Scheme |
retrying: after catching an exception, tell the snippet to be re-run
retry | Eiffel, Ruby, Smalltalk |
restart | Dylan |
resume execution where the exception took place
resume | Smalltalk |
call-with-current-continuation(9) | Scheme |
callcc | Ruby, SML-NJ |