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 { }. The separators space, ; and ◇ have different meanings in each kind of bracket. 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:
To keep an expression containing spaces as one bracket item, put it 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:
You can’t use both ; and ◇ inside the same pair of brackets.
Brackets are not used for indexing. To select from an array, use 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, which can have different lengths. 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 ; at the top level raises a SYNTAX error.