Skip to content
KEC Lisp

KEC Lisp

A small Lisp. The scripting language for the KN-86 Deckline — usable on its own, on a normal computer, with no device hardware.
(defn fizzbuzz (n)
(dotimes (i n)
(let k (+ i 1))
(princ (cond ((is (mod k 15) 0) "FizzBuzz")
((is (mod k 3) 0) "Fizz")
((is (mod k 5) 0) "Buzz")
(else (number->string k))))
(newline)))
(fizzbuzz 15)

What it is

KEC Lisp is built on Fe — rxi’s tiny Lisp — plus a standard library written in Lisp (core/) and a handful of portable C primitives (host/). It ships as the interpreter, the library, a kec command-line tool, and a test suite.

The syntax is small and Lisp-shaped: code is written as s-expressions, calls are prefix forms, and lists are the main data structure. Bind names with define, defn, and let; mutate them with set; branch with if and cond; pass functions around with fn, map, filter, and folds.

Documentation

  • Getting Started — build the kec binary, run the REPL, write your first program.
  • Language Reference — the kernel, the standard library, and the runtime/host primitives.
  • Built-ins — the 26 kernel primitives, with one-line semantics.
  • FFI Bridge — add your own C primitives: the bind seam and marshalling rules.
  • Memory Model — one context, one arena. How allocation and resets work.
  • Language Standard — the layer model: Fe Kernel · KEC Core · Host · firmware.
  • Fe Kernel — Internals — object encoding, GC mechanics, known constraints, and KEC additions to upstream Fe.

A taste

; bind with define / defn / let; mutate with set; compare with = / ==
(define greeting "deckline")
(str "hello, " greeting) ; => "hello, deckline" (str concatenates)
(map (fn (x) (* x x)) (range 1 6)) ; => (1 4 9 16 25)
(filter odd? (range 1 10)) ; => (1 3 5 7 9)
(fold-left + 0 (range 1 101)) ; => 5050

nil is the only false value and the empty list. Numbers are single-precision floats. = and == are value equality; assignment is set (a deliberate change from upstream Fe). See the Language Reference for the full story.