a←1
b←2
[a b]1 2
;, ⋄ and line breaks mean inside brackets, parentheses and braces
BPL has three kinds of bracket: brackets [ ], parentheses ( ) and braces { }. Each gives its own meaning to the separators space, ; and ⋄. A line break means ⋄, except just inside a bracket or next to ;, ⋄ or ?, where it separates nothing. For what brackets and braces create, see Arrays and Dfns.
| Inside | Space | ; |
⋄ or a line break |
|---|---|---|---|
[ ] |
Separates items | Separates items that contain spaces | Separates rows of an array |
( ) |
Separates runs | Not allowed | Separates rows of a vector |
{ } |
Separates runs | Separates bodies | Separates statements |
| Top level | Separates runs | Not allowed | Separates statements |
A run is a sequence of tokens with no spaces between them. Syntax gives the rules for runs.
Brackets are used to write vectors. Inside brackets, spaces separate items:
An item can be any expression without spaces:
An item can use a name that an earlier item assigns, because items are evaluated left to right:
An item that needs spaces goes in parentheses:
When several items need spaces, separate them with ; and write each item as you would outside brackets:
A ; list can run over several lines, because a line break after ; separates nothing:
With ⋄ or a line break, a bracket list is an array whose major cells are the rows:
Rows of different lengths are padded with fill:
One pair of brackets can’t use both ; and ⋄.
Brackets don’t index. Selection uses Index, ⌷, or a subscript for one position.
Parentheses group one expression, read as it would be at the top level:
With ⋄, a parenthesised list is a vector of rows of any length. A row with one item is still a vector:
Inside parentheses, a line break starts a new row, as ⋄ does, rather than continuing the expression:
In brackets, the same rows form one array, padded with fill:
Braces define a function, whose statements are separated by ⋄ or line breaks:
When a body’s predicate C? is false, evaluation moves on to the next body after ;:
Outside any bracket, ⋄ and line breaks separate statements. A ; there is a SYNTAX error.