On this page:
#%literal
#%literal
#%literal
#%literal
#%parens
#%parens
#%parens
#%body
8.12

6.20 Implicit Forms🔗ℹ

Rhombus parsing is driven by bindings even for forms that have no apparent name, such as a literal expression like 7 or square brackets like [1, 2, 3]. In those cases without an apparent name an implement form is used to give meaning to the term, whether in an expression position, binding position, or other kind of position. For positions that allow only prefix operators, such as definition positions, only prefix implicits are used. Here are all of the implicit forms:

expression

#%literal literal

 

binding operator

#%literal literal

 

annotation

#%literal literal

 

repetition

#%literal literal

Produces the value literal as an expression or matches values that are == to literal as a binding; the annotation form reports an error that a literal is not allowed as an annotation. A literal also works as a repetition of depth 0, which can be useful for repeating a constant alongside a repetition of greater depth.

A literal is any individual term other than an identifier, keyword, operator, parenthesized term, bracketed term, braced term, quoted term, block, or alternatives.

> 7

7

> #%literal 7

7

> fun only_sevens(7): "yes"

> only_sevens(7)

"yes"

> only_sevens(8)

only_sevens: argument does not satisfy annotation

  argument: 8

  annotation: matching(7)

expression

#%parens (expr)

 

binding operator

#%parens (bind)

 

annotation

#%parens (annot)

Provided both normally and as meta.

Produces the same value as expr, same binding as bind, and so on. Multiple expression, bindings, etc., are disallowed.

> (1+2)

3

> #%parens (1+2)

3

> def (x) = 1+2

> x

3

expression

#%body:

  body

  ...

Returns the result of the body block, which may include local definitions. The body sequence does not implicitly use #%body again.