17.14.4 Sequence Macros
class clause | |||
| |||
| |||
interface clause | |||
| |||
| |||
veneer clause | |||
|
The input pattern is matched to each_id ...: each_expr where each_expr is a parsed expression for the right-hand side of each, and the number of each_ids reflects the number of expected result values. The result of the body sequence must be either #false, in which case the implementation falls back to dynamic mode, or a syntax object of the form
'(~outer_binds:
outer_bind: outer_body; ... // `=` allowed instead of `:`
...,
~outer_check:
...,
~recur_binds:
...,
~head_guard:
...,
~inner_binds:
inner_bind: inner_body; ... // `=` allowed instead of `:`
...,
~pre_guard:
...,
~post_guard:
...,
~recur_args:
(recur_arg_expr, ...))'
The keywords in this shape must appear in the shown order, but each is optional and defaults to either an empty binding sequence or a body sequence that produces #true.
These pieces are integrated into a larger expression of roughly the following form, where loop_body is an iteration body, and done_expr is the reducer-generated result.
// bind and/or unpack the sequence
def outer_bind: outer_body; ...
...
// maybe check that sequence is valid
...
// bind loop arguments, especially as the iteration position
...
if (block: head_guard_body; ...) // check continues at this position
| def inner_bind: inner_body; ... // bind variables for element
...
if (block: pre_guard_body; ...) // check continues for this element
...
if (block: post_guard_body; ...) // check continues *after* this
| loop(recur_arg_expr, ...) // update the position for next iteration
loop()
Typically, the inner_binds include the the each_ids supplied to the match for pattern, so they can be referenced in loop_body. However, the each_ids are not the same as the identifiers used in the triggering each form. Static information for identifier bounds by each comes from statinfo_meta.index_result_key static information for the enclosing class or interface.
~initial_position: 0,
)
'(~outer_binds:
~recur_binds:
pos = 0,
~head_guard:
pos < 2,
~inner_binds:
~recur_args:
(pos + 1))'
$(annot_meta.parse_to_packed_statinfo('Int'))))'