17.14.11 Immediate Callee Macros
An immediate callee position is one, such as the right-hand side of |>, that can have a general expression, but where the result of the expression will be applied immediately to a specific number of arguments, and static information is available for the arguments. An immediate callee can thus support more static-information propagation than would normally take place at a function call.
space | |
definition | ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||
|
The value bound to statinfo_id is a list with as many elements as arguments to be supplied to this callee. Each element of the list is unpacked static information for that argument.
The value bound to in_op_mode_id is either #'prefix or #'infix, indicating whether in_op_stx_id is being parsed as a prefix or infix operator.
The value bound to in_op_stx_id is a name for the expression form or operator that has this immediate callee. For example, in_op_stx_id might be '|>'. This operator or identifier may be needed with expr_meta.ends_parse to parse the immediate callee form, since a would-be callee may actually be a subexpression in a larger expression, so not actually a callee.
The result of expansion can be either a single group or a group for the parsed result and a group for the remaining tail. The resulting parsed group can be an immediate callee form or an expression form, where the latter is assumed if the result does not start with an identifier (possibly implicit) that is bound as an immediate callee macro. If a tail is returned, then the parsed result is further parsed as a delimited group, otherwise it is (re-)parsed as a continuation of the form that contains the immediate callee.
immediate_callee.macro 'enlist $tail ...':
~op_stx: all
~static_infos: sis
~in_op_mode mode
~in_op_stx op
if expr_meta.ends_parse(mode, op, '$tail ...')
| // parse as callee
let res = annot_meta.pack_predicate('fun (x): #true',
sis[0])
'$tail ...')
| // parse as expression
> ("apple" |> enlist)[0][0]
Char"a"
syntax class | ||||
|
Analogous to expr_meta.Parsed, but for parsing immediate callees. The static_infoss argument should be a list of syntax object unpacked static information. The op_mode argument and op_stx arguments specify the operator that triggered the parse, where op_mode is #'prefix or #'infix and os_stx is a name.