Vocabulary/ControlStructures

From J Wiki
Jump to navigation Jump to search

Back to: Vocabulary

Control words are used in Explicit Definition (:) and are punctuation that determine the sequence of execution. Matching control words and the enclosed sentences make up a control structure.

The following control words and structures are available, where words beginning with B or T denote sentence blocks:

assert. T Trigger error
break. Terminate loop
continue. Terminate iteration
for.     T do. B end.
for_xyz. T do. B end.
Repeat for
goto_lbl.
label_lbl.
Go to label
if. T do. B end.
if. T do. B else. B1 end.

if.     T  do. B
elseif. T1 do. B1
elseif. T2 do. B2
else. B3
end.

Execute if /
Execute alternative
return. Exit with result
select. T
 case.  T0 do. B0
 fcase. T1 do. B1
 case.  T2 do. B2
end.
Execute case
throw. Execute throw
try. B
 catch.  B1
 catchd. B2
 catcht. B3
end.
Execute try
while.
whilst.
Execute while