6 Implicit Operators
In much the same way that #%app and #%datum are implicitly used in many Racket expressions, Rhombus enforestation needs at least two implicit forms: an implicit prefix operator for a non-identifier form by itself (somewhat like #%datum), and an implicit infix operator for the juxtaposition of a parsed form and another form without a binary operator in between (somewhat like #%app). To help enforestation applications avoid a level of indirection between those minimal implicit forms, however, enforestation is parameterized over functions that select implicit prefix and infix forms. The default selection function generates references to the following forms:
#%parens: implicit prefix for a parenthesized term that is not immediately after a parsed form
#%call: implicit infix for a parsed form followed by a parenthesized term
#%brackets: implicit prefix for a square-bracketed term that is not immediately after a parsed form
#%index: implicit infix for a parsed form followed by a square-bracketed term
#%braces: implicit prefix for a curly-braced term that is not immediately after a parsed form
#%comp: implicit infix for a parsed form followed by a curly-braced term
#%juxtapose: implicit infix for adjacent expressions with no operator between them when #%call, #%index, and #%comp do not apply
#%quotes: implicit prefix for a single-quoted term that is not immediately after a parsed form
#%block: implicit prefix for a block (written with :) not immediately after a parsed form
#%alts: implicit prefix for a sequence of alternatives (written with | notation) not immediately after a parsed form
#%literal: implicit prefix for a literal, such as a number or boolean, not immediately after a parsed form
In an expression context, a Rhombus language’s #%call implementation most likely creates a function call, #%parens most likely does nothing for a single expression in parentheses (so parentheses can be used for grouping) and might otherwise create a tuple value or return multiple values, #%juxtapose probably reports an error. Implicit operators are likely to have the highest possible precedence and be left-associative, but they are not constrained to those conventions by the Rhombus expander. Implicit operators are likely to be implemented using the macro operator protocol instead of the automatic operator protocol.