x-lang

x-lang syntax: the preferred forms

The syntax of booted x-lang and the idioms this project prefers — the least-surprise contract. Every ruling here is implemented; the ruling record is issue #45. The bare layer underneath is syntax-bare.md.

Symbols and quoting

Write 'x, always, in any code that loads after boot. (lit x) is the boot-layer mechanism — the operative the quote reader expands to — and its spelling belongs only in files that load before the quote reader (the boot block) and in discussions of the mechanism itself.

(prim-ref 'buf 'tok)        ; preferred
(prim-ref (lit buf) (lit tok)) ; boot-layer files only
'(a . 1)                    ; a quoted assoc
'(a b c)                    ; quoted list

The REPL echoes symbols as 'a and quoted structures with the same shorthand — the echo pastes back. (Implemented: the printer’s ' shorthand is live; (lit a) echoes are history.)

`x, ,x, ,@x are the quasiquote family; the printer already echoes them in shorthand.

Numbers

Characters and strings

Collections

Idioms

The echo (what the REPL prints back)

You type It echoes
'a 'a
42, -7, "s", #\a, #t itself
#(1 2 3), 1/2, 3.14, 3+4i itself (tower forms in tower dialects)
`(a ,x) quasi shorthand
a list value ('a 'b) — quoted elements, pasteable
fn / op / dict / instance #<…> opaque — deliberately not pasteable
() (blank)

Dialect matrix

Syntax bare x helium xenon/radon, x-base
ints (signed, hex), strings, #\ chars, lists, ( . x), ;
#t/#f as booleans, printer
' ` , ,@ #"…" #(…)
floats, rationals, complexes, bigints, decimals (1.5d), #/…/

The bare column is normative for every implementation of the reader; see syntax-bare.md.