--- 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

Clojure's spellings. Forma's types.

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.

orders.lispa conformance fixture
<<< @/snippets/clojure/orders.excerpt.lisp{lisp fragment}

Stage 0 of RFC 0021 · where Clojure habits stop

01 Scope

What ships, and what does not.

"Clojure support" could mean four different things. Exactly one of them exists today, and this page is only about that one.

| | What it would mean | Status | | --- | --- | --- | | **A spelling library** | Clojure's familiar heads as macros over Forma semantics | Shipped `preludes/modules/clojure.lisp`, this page | | **A Clojure surface** | A language with Clojure's reader, `(:key m)`, `#{...}`, and its own diagnostics | Proposed RFC 0021 stage 5 | | **A Clojure adapter** | Typechecking existing `.clj` files, with declaration files and a gradual boundary | Proposed RFC 0022 stage 5 | | **A Clojure backend** | Emitting `.cljc` that runs on the JVM and in ClojureScript | Proposed RFC 0021 stage 6 | | **Today** | Write Forma, spell it like Clojure, run it on the Forma engine | Nothing on this page runs on a JVM |
The library exists because of one small engine change. Forma used to reject `def`, `defn`, `defmacro`, `lambda`, and `let*` in the reader, before any library could claim them. Those spellings are now rejected *after* expansion, so a macro in scope may define what they mean — and if none is, the old message still arrives at the form you wrote:
report.lisp, with nothing importedreal diagnostic
<<< @/snippets/clojure/unimported.txt

02 The library

Eight macros, and nothing privileged.

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.

preludes/modules/clojure.lispbundled library, verbatim
<<< @/../preludes/modules/clojure.lisp{lisp fragment}

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-let

Expand to match on Option. They bind the value inside Some; they do not test truthiness.

if-not, when-not, comment

Ordinary 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

A module that reads like Clojure and checks like Forma.

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.

conformance/clojure-spellings/orders.lispthe source
<<< @/../conformance/clojure-spellings/orders.lisp{lisp fragment}
the checked interfaceinferred, not written
<<< @/snippets/clojure/orders.checked.txt
Three things in that output are worth naming. - **The annotations are checked, not decorative.** `(: quote-for (-> Int (Option Int) String))` is verified against the body. Drop it and inference still runs, but unannotated arithmetic widens to `Float`, so the signature you get is `(-> Float (Option Float) String)`. - **`receipt` was evaluated while the module was checked.** `"4400 cents"` is a compile-time value in the module's interface, not a test assertion written by hand. - **The coupon is an `Option Int`.** `if-let` binds what is inside `Some`. There is no truthy value and no nil to pun on, which is the whole difference between this library and Clojure.

04 Where habits stop

Four Clojure reflexes the library does not carry over.

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.

truthiness: (if coupon …)real diagnostic
<<< @/snippets/clojure/truthiness.txt
nil punning: nil for absencereal diagnostic
<<< @/snippets/clojure/nil-punning.txt
keyword access: (:customer order)real diagnostic
<<< @/snippets/clojure/keyword-access.txt
set literal: #{"new" "vip"}real diagnostic
<<< @/snippets/clojure/set-literal.txt
The first two are the design working: Forma's semantics win, and the error lands on the author's expression. The last two are the design's current edge. `(:key m)` and `#{…}` are not spellings a macro can claim — one needs an application-with-a-non-symbol-head rule, the other a reader switch. RFC 0021 calls these interposition points and lexical profiles, and they arrive with a surface, not with a macro library. Use `(get m :key)` until then.

05 Limits

Known rough edges.

Everything below is current behavior, not a plan.

The measurement that decides whether this goes further is an agent benchmark: do models writing Forma need fewer repair rounds when their Clojure habits parse? RFC 0021 holds its later stages behind that result.

06 What's next

From spellings to a surface to a target.

Each step is a proposal with a gate, and none is scheduled.

| Step | What changes | Where it is written down | | --- | --- | --- | | **A Clojure surface** | A `language` declaration: a reader profile for `#{…}` and `#(…)`, `(:key m)` as an application rule, diagnostics in Clojure's terms, and `dialect/unsupported` naming each construct it cannot check | [RFC 0021](https://github.com/bjacobso/forma/blob/main/docs/rfcs/0021-languages-as-libraries.md) stage 5 | | **A trusted kernel** | A small checker that re-checks every elaborated program, so a surface cannot make an ill-typed program pass | [RFC 0022](https://github.com/bjacobso/forma/blob/main/docs/rfcs/0022-programmable-type-system.md) stage 1 | | **A Clojure adapter** | Checking existing Clojure source through declaration files, `Dynamic`, and casts | [RFC 0022](https://github.com/bjacobso/forma/blob/main/docs/rfcs/0022-programmable-type-system.md) stage 5 | | **A `.cljc` backend** | Running the surface backwards over checked core terms, plus a kernel port and differential conformance against the TypeScript VM | [RFC 0021](https://github.com/bjacobso/forma/blob/main/docs/rfcs/0021-languages-as-libraries.md) stage 6 | | **Today** | A macro library, one import away | [The library above](#library) |
Racket, Scheme, and Common Lisp follow the same route, in that order. The homepage's [Lisp targets section](/#targets) has the short version, and RFC 0022's "Lisp targets" has the semantic gaps and the gate for each.

Try the spellings in the browser.

The Clojure sandbox mounts preludes/modules/clojure.lisp as an editable package alongside a checked pipeline module.