Skip to content

Commit

Permalink
add some documentation about *=
Browse files Browse the repository at this point in the history
  • Loading branch information
nathanielnrn committed Feb 5, 2024
1 parent 7262a54 commit f558c28
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion docs/builder/ref.md
Original file line number Diff line number Diff line change
Expand Up @@ -257,11 +257,14 @@ my_component.control += my_component.get_group("my_group")

### `seq`

Control statements are [sequenced][seq] in the order that they appear in a component's control program, represented by a Python list. Let's say we want to sequence the control statements `A`, `B`, and `C`.
Control statements are [sequenced][seq] in the order that they appear in a component's
control program, represented by a Python list.
Let's say we want to sequence the control statements `A`, `B`, and `C`.

```python
my_component.control += [A, B, C]
```
It's worth nothing that sequential usage of `+=` will not nest `seq` blocks unless necessary.

### `par`

Expand All @@ -271,6 +274,30 @@ For [parallel compositions][par] of control programs, use the `par()` function.
my_component.control += [par(A, B), C]
```

Alternatively, we can construct `par` blocks by using `*=`. To compose the same control program as above, with `A` and `B` in parallel and sequencing this composition before `C` we could write:

```python
my_component.control *= par(A,B)
my_component.control += C
```

### Chaining `seq` and `par`

It is possible to chain together sequential usage of `+=` and `*=` to construct a control program ``sequentially''.
In this way, the control program's construction in the builder will look similar to the control program in the output Calyx. For example,
the previous python example in the `par` section will produce a par block of `A` and `B`, which is sequenced before `C`:

```
seq{
par{
A;
B;
}
C;
}
```

### `if`

See the language reference for [`if`][if].
Expand Down

0 comments on commit f558c28

Please sign in to comment.