Skip to content
TurtleKitty edited this page May 12, 2019 · 2 revisions

reader literals

The Vaquero reader recognizes several data structures.

It reads null, true, false, and numbers as themselves.

null     ; null
true     ; true
false    ; false
2        ; int
6.28     ; real
1/2      ; real

Quoted strings of characters are read as texts.

"Shallow Then Halo"  ; text

There are also the #(text ...) and #(template ...) forms for generating texts.

#(text ((\w+)\s*:\s*((\w+)&(\d+))))
    ; "((\\w+)\\s*:\\s*((\\w+)&(\\d+)))"

(let (x 2 y 3)
    #(template x: {{ x }} y: {{ y }} (z: {{ (+ x y) }})))
        ; "x: 2 y: 3 (z: 5)"

List literals are interpreted as code unless quoted, except for the empty list (), which is self-evaluating.

(foo bar baz)           ; apply function foo to arguments bar and baz
(quote (foo bar baz))   ; (foo bar baz)
()                      ; ()

The single-quote (') is shorthand for (quote ...).

'foo     ; (quote foo)
'(x y z) ; (quote (x y z))

The percent sign (%) is shorthand for (qq ...).
Within a qq, dollar-sign ($) and at-sign (@) are shorthand for (unq ...) and (unqs ...).

(def x 1)
(def y (list 2 3)) 
%(foo x y $x $y @y)
; (qq (foo x y (unq x) (unq y) (unqs y)))
; (foo x y 1 (2 3) 2 3)

Semicolons comment out the rest of a line.

(+ 1 2) ; this is a comment

The #(doc ...) form comments out multple lines.

#(doc
   This module is a hack, and a really bad idea, but I'm short on time.
   (this list is never evaluated.))

Built-in structures can be read with #( ...).

#(cell 7)                  ; #(cell 7)
#(pair x y)                ; (x . y)
#(table x 1 y 2 z (+ x y)) ; #(table x 1 z (+ x y) y 2)
#(vector x y z (1 2 3))    ; #(vector x y z (1 2 3))
#(set 3 4 5)               ; #(set 5 4 3)
#(tuple x 2 y 3)           ; #(tuple y 3 x 2)
Clone this wiki locally