On this page:
dot
dot.macro
dot
dot
dot
8.12

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'

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, a . term, and a right-hand identifier. The defined_name is bound in the dot space.

Two extra options are supported: ~is_static and ~tail. 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 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 that is dynamic and generic—unless the . operator is in static mode, in which case it will report a syntax error. A (first) syntax-object result provides an expression form (that normally includes the left-hand expression) 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'

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 or initerface name, which is treated as (obj_expr :: name).defined_id.

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 name.defined_id(obj_expr).