Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

spec: Rephrase confusing paragraph about TailLoop inputs/outputs #567

Merged
merged 3 commits into from
Oct 16, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 14 additions & 7 deletions specification/hugr.md
Original file line number Diff line number Diff line change
Expand Up @@ -369,13 +369,20 @@ flowchart

##### `TailLoop` nodes

These provide tail-controlled loops: the data sibling graph within the
TailLoop-node computes a value of 2-ary `Predicate(#i, #o)`; the first
variant means to repeat the loop with the values of the tuple unpacked
and “fed” in at at the top; the second variant means to exit the loop
with those values unpacked. The graph may additionally take in a row
`#x` (appended to `#i`) and return the same row (appended to `#o`). The
contained graph may thus be evaluated more than once.
These provide tail-controlled loops. The dataflow sibling graph within the
TailLoop-node defines the loop body: this computes a row of outputs, whose
first element has type `Predicate(#I, #O)` and the remainder is a row `#X`
(perhaps empty). Inputs to the contained graph and to the TailLoop node itself
are the row `#I:#X`, where `:` indicates row concatenation (with the tuple
inside the `Predicate` unpacked).

Evaluation of the node begins by feeding the node inputs into the child graph
and evaluating it. The `Predicate` produced controls iteration of the loop:
* The first variant (`#I`) means that these values, along with the other
sibling-graph outputs `#X`, are fed back into the top of the loop,
and the body is evaluated again (thus perhaps many times)
* The second variant (`#O`) means that evaluation of the `TailLoop` node
terminates, returning all the values produced as a row of outputs `#O:#X`.

##### Control Flow Graphs

Expand Down