On this page:
immediate_  callee
immediate_  callee.macro
immediate_  callee_  meta.Parsed
8.13.0.9
7.13.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.

The space for bindings of identifiers that can be used in immediate callee positions.

definition

immediate_callee.macro prefix_macro_patterns

 

option

 = 

~op_stx: id

 | 

~op_stx id

 | 

~static_infos: statinfo_id

 | 

~static_infos statinfo_id

 | 

~in_op_mode: in_op_mode_id

 | 

~in_op_mode in_op_mode_id

 | 

~in_op_stx: in_op_stx_id

 | 

~in_op_stx in_op_stx_id

Like defn.macro, but defines an identifier as an immediate callee form in the immediate_callee space. Also, in addition to the ~op_stx option, the ~static_infos, ~in_op_stx, and/or ~in_op_mode “options” can be specified to receive information about the callee context:

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])

    values('fun (x) :~ List.of($res): [x]',

           '$tail ...')

  | // parse as expression

    'dynamic(enlist) $tail ...'

> use_static

> ("apple" |> enlist)[0][0]

#{#\a}

syntax class

syntax_class immediate_callee_meta.Parsed(static_infoss, op_mode, op_stx):

  kind: ~group

  fields:

    group

Provided as meta.

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.