17.11 Dot Providers
space | |
definition | ||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||
|
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—
class clause | ||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||
interface clause | ||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||
veneer clause | ||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||
| ||||||||||||||||||||||||||||||||||||||||
|
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).