17.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, [0, 1, 2], 1, 0, ())')
> [nat3, ...]
[0, 1, 2]
Packs the implementation of a repetition form to serve as the result of expanding a repetition macro, where the repetition is described in terms of for clauses and a body.
The syntax object stx must have the following shape:
'(
source_form,
((((id, ...), seq_expr),
...),
...),
body_expr,
use_depth,
((static_key, static_value), ...)
)'
The source_form group is used for error reporting to show the repetition, such as when the repetition is used at the wrong depth.
Each (id, ...) sequence names values of elements drawn from the corresponding seq_expr. Each inner sequence of seq_exprs corresponds to sequences traversed in parallel, while the outermost sequence corresponds to sets of sequences that are nested. The length of the outermost sequence determines the depth of the repetition.
The body_expr expression produces elements of the repetition, usually referring to the ids that are bound to input sequence elements, and only the ids that are in the last parallel group.
The use_depth integer specifies how much additional depth has already been extracted from an original repetition; 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 individual elements of the repetition. This information is automatically packed via statinfo_meta.pack.
The inverse of repet_meta.pack_generator, which is useful for unpacking information about the expansion of nested repetition forms.
Any repetition can be unpacked both this way and by using repet_meta.unpack_list, but the output repet_meta.unpack_generator is more flexible for most purposes.
repet.macro 'enumed($from, $(sub :: repet_meta.Parsed))':
~all_stx stx
let '($_, ($binds, ..., ($inner_bind, ...)), $body, $use_depth, $_)':
'($stx,
[i, $body],
$use_depth,
$si)'
)
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. See repet_meta.pack_generator for an alternative representation.
The syntax object stx must have the following shape:
'(
source_form,
list_expr,
depth,
use_depth,
((static_key, static_value), ...)
)'
The source_form group is used for error reporting to show the repetition, such as when the repetition 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 list_expr expression produces a List that contains the elements of the repetition. Lists must be nested according to the repetition’s depth: a list of elements for depth 1, a list of element lists for depth 2, and so on.
The depth integer specifies the depth of the repetition. The use_depth specifies how much additional depth has already been extracted from an original repetition; 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 individual elements of the repetition. This information is automatically packed via statinfo_meta.pack.
The inverse of repet_meta.pack_list, which is useful for unpacking information about the expansion of nested repetition forms.
Any repetition can be unpacked both this way and by using repet_meta.unpack_generator. The result of repet_meta.unpack_list can be convenient, but its use can be less efficient if a refied list is simply fed into another for-like traversal.
repet.macro 'enumed($from, $(sub :: repet_meta.Parsed))':
~all_stx stx
'($stx,
$depth,
$use_depth,
$si)'
)
syntax class | ||||||
| ||||||
| ||||||
syntax class | ||||||
| ||||||
| ||||||
syntax class | ||||||
| ||||||
| ||||||
syntax class | ||||||
|
Analogous to expr_meta.Parsed, etc., but for repetition forms.
function | ||||
|
Analogous to expr_meta.parse_dot, but for repetitions.
To select a specific dot provider, use repet_meta.unpack_list plus repet_meta.pack_list to adjust the static information of left, where statinfo_meta.dot_provider_key is the relevant static-information key.