def, defn, defn-
Expand to define. A docstring or attribute map before the parameter vector is accepted and dropped, because define has no docstring slot.
--- layout: home title: Clojure spellings in Forma description: preludes/modules/clojure.lisp is an ordinary macro library that gives Forma modules Clojure's spellings — def, defn, defn-, if-let, when-let, if-not, when-not, comment, and threading. It changes spelling, not semantics; types, nil, and numbers stay Forma's. sidebar: false aside: false pageClass: forma-index ---
Clojure in Forma · a shipped library · pre-alpha
Eight macros in one file, imported like any other module.
preludes/modules/clojure.lisp gives a module def, defn, defn-, if-let, when-let, if-not, when-not, comment, and threading. Every one is an ordinary macro that expands to core Forma, so the program it produces is checked by Hindley–Milner inference and carries Forma's effects and contracts. It is spelling, not semantics: if takes a Bool, absence is Option, and nil is a Unit value.
Stage 0 of RFC 0021 · where Clojure habits stop
01 Scope
"Clojure support" could mean four different things. Exactly one of them exists today, and this page is only about that one.
02 The library
This is the whole thing. Each macro is a template over core Forma: defn builds a define of a fn, and if-let builds a match on Option. Nothing here is privileged — a prelude you write has the same powers.
def, defn, defn-Expand to define. A docstring or attribute map before the parameter vector is accepted and dropped, because define has no docstring slot.
if-let, when-letExpand to match on Option. They bind the value inside Some; they do not test truthiness.
if-not, when-not, commentOrdinary templates. when-not yields nil, which in Forma is a Unit value.
->, ->>Re-exported from kernel.lisp, where they already lived. Threading is the one Clojure habit Forma always had.
03 An example
This is a conformance fixture, not a sketch. The engine checks it on every run of pnpm check, and the interface below is its own output.
04 Where habits stop
Each block is the compiler's own diagnostic for a fixture in the repository, located at the line and column you wrote — inside the defn body, not inside the macro expansion.
05 Limits
Everything below is current behavior, not a plan.
defn fails with an arity error raised inside the macro, with no message and no span in your file. It is pinned as a fixture so that fixing it is visible.gapwhen-let wants a Unit bodyIts None branch is nil, so a body that returns a value unifies that value with Unit. (defn f [o] (when-let [v o] v)) infers (-> (Option Unit) Unit) instead of failing.gapdefn accepts a docstring and an attribute map and discards both, because define has no docstring slot.gapdefn- does not make anything privateForma modules export by name, so defn- is defn. A name is private because it is absent from export.by designdefn still reports the retired spelling.by design06 What's next
Each step is a proposal with a gate, and none is scheduled.
The Clojure sandbox mounts preludes/modules/clojure.lisp as an editable package alongside a checked pipeline module.