On this page:
dot
dot.macro
dot
dot
dot
8.13.0.9

7.11 Dot Providers🔗ℹ

space

dot

The space for bindings of identifiers as dot providers.

definition

dot.macro prefix_macro_patterns

 

option

 = 

~op_stx: id

 | 

~op_stx id

 | 

~is_static: id

 | 

~is_static id

 | 

~tail: 'pattern'

 | 

~tail 'pattern'

 | 

~is_repet: id

 | 

~is_repet id

Similar to defn.macro, but binds a dot provider that is normally referenced indirectly via static information, instead of directly. The pattern sequence after the leading defined_name should match a sequence of three terms: a parsed left-hand expression or repetition, a . term, and a right-hand identifier. The defined_name is bound in the dot space.

If the ~is_repet option is specified, then the dot provider can be called in either expression or repetition mode, where the left-hand term and the result correspond to the mode. The dot provider is only called in expression mode if the ~is_repet option is not specified for any pattern case.

Compared to defn.macro, three extra options are supported: ~is_static, ~tail, and ~is_repet. The identifier for ~is_static is bound to #true or #false, depending on whether the use of . to reach the provider was a static or dynamic dot; see use_static. The pattern for ~tail is matched to the tail of the enclosing group after the . and subsequent identifier. If the ~tail pattern doesn’t match, then the case containing the ~tail pattern does not match, which is useful in a multi-case dot.macro form. The ~is_repet identifier is bound to #true or #false, depending on whether the dot provider is called in repetition or expression mode.

The result must be either #false, a syntax object, or two syntax-object values. A #false result means that static resolution failed, in which case the . operator will generate a fallback lookup. In repetition mode, the fallback is to try expression mode. In expression mode, the fallback implements a lookup that is dynamic and generic—unless the . operator is in static mode, in which case the fallback will report a syntax error. A (first) syntax-object result provides an expression or repetition form (that normally includes the left-hand expression or repetition) to replace the . expression. When a second syntax-object result is provided, it is used as the remainder of the enclosing group for further processing, and the default result is the same tail that would be provided for an identifier declared with the ~tail option.

class clause

dot '$left_id . defined_id':

  option; ...

  body

  ...

 

interface clause

dot '$left_id . defined_id':

  option; ...

  body

  ...

 

veneer clause

dot '$left_id . defined_id':

  option; ...

  body

  ...

 

option

 = 

~op_stx: id

 | 

~op_stx id

 | 

~head_stx: id

 | 

~head_stx id

 | 

~is_static: id

 | 

~is_static id

 | 

~tail: 'pattern'

 | 

~tail 'pattern'

 | 

~is_repet: id

 | 

~is_repet id

A form for class, interface, or veneer to bind a macro that is normally triggered by using the defined_id after . on an expression that has the class’s or interface’s annotation. The macro can also be triggered by name.defined_id(obj_expr) for a class, interface, or veneer name (more specifically, for the defined namespace), in which case the obj_expr is checked to be a correct instance.

The pattern for dot is constrained to have an escape for left_id as the left-hand expression (which has the class or interface annotation), a literal ., and then an identifier for defined_id.

The options and result body are as for dot.macro, except that ~head_stx is also allowed as an option. An identifier after ~head_stx is bound to the called form, either obj_expr.defined_id or defined_id(obj_expr).