Logos special forms reference
Copy MarkdownExactly six forms are wired directly into Logos.Eval -- everything else is a macro built from these plus primitives, defined across priv/stdlib/*.logos. For prose/narrative explanation and worked examples, see the language reference; for everything else generated (the overview, special forms, primitives, and every other stdlib namespace), see the other pages in this "Stdlib Reference" section.
quote
(quote form) / 'form
Suppresses evaluation. Nothing else can.
Example:
(quote (1 2 3))
;;=> (1 2 3)cond
(cond test1 expr1 test2 expr2 ...)
The one primitive conditional. Only the first taken branch is evaluated -- an even count of clauses with no default falls through to nil; a dangling final test with no matching expression is an error.
Example:
(cond false 1 true 2)
;;=> 2do
(do form1 form2 ... formN)
Sequencing; evaluates every form, returns the last. (do) is nil.
Example:
(do 1 2 3)
;;=> 3def
(def name value) / (def name "doc" value)
Interns/updates a Var in the current namespace. name must be unqualified; def's own result is the defined symbol (ns/name), not the value.
Example:
(def answer 42)
;;=> user/answerfn
(fn [params...] body...) / (fn ([p1] b1) ([p1 p2] b2))
Builds a closure over the lexical environment. &rest marks a variadic tail param. Multi-arity via the second shape.
Example:
((fn [x] (* x x)) 5)
;;=> 25try
(try body... (catch tag e handler...) (finally cleanup...))
Interposes on Logos-level throw. catch/finally are syntax inside try, not separate forms; both are optional, any number of catch clauses.
Example:
(try (throw :oops "bad") (catch :oops e e))
;;=> "bad"