7.12 Repetition Macros
space |
value |
A compile-time value that identifies the same space as repet. See also SpaceMeta.
definition |
repet.macro 'nat3':
~op_stx self
repet_meta.pack_list('($self, n, PairList[0, 1, 2], 1, 0, (), #true)')
> [nat3, ...]
[0, 1, 2]
Packs the implementation of a repetition form to serve as the result of expanding a repetition macro, where elements of the repetition are provided through a list.
The syntax object stx must have the following shape:
'(source_form,
name_id,
pair_list_expr,
total_depth,
use_depth,
((static_key, static_value), ...),
is_immediate)'
The source_form group is used for error repoting to show the repetition, such as when the repeition is used at the wrong depth.
The name_id term is for error reporting and reflection in the sense that it is used as the inferred name for an element of the repetition, in case such a name is relevant.
The pair_list_expr expression produces a PairList that contains the elements of the repetition. Lists must be nested according to the repeition’s depth: a list of elements for depth 1, a list of element lists for depth 2, and so on.
The total_depth integer specifies the depth of the original repetition, while use_depth specifies how much of the original depth has already been extracted; that is, the difference total_depth minus use_depth indicates the depth of the list nesting that is produced by list_expr. A non-zero use_depth might be relevant to reporting the use of a repetition at the wrong depth in terms of the original form’s depth.
The static_key–static_value pairs describe “upward” static information for inidvidual elements of the repeition. This information is automatically packed via statinfo_meta.pack.
The is_immediate component must be a literal boolean. A #true indicates that list_expr can be efficiently evaluated multiple times, while #false indicates that list_expr should be lifted out of enclosing repetitions to avoid evaluating it multiple times.
The inverse of repet_meta.pack_list, which is useful for unpacking information about the expansion of nested repetation forms.