Lisp Comparison With Alcove

Lisp Comparison With Alcove

This is an Alcove-focused side-by-side Lisp reference inspired by Hyperpolyglot’s Lisp comparison. It is not a copy of that page: the rows are reorganized for Alcove, and the Alcove columns cover the current implementation in this repository.

Adder (file extension .adr) is a surface reader for Alcove forms: it omits the outer parentheses for calls (is a b, not (is a b)) and uses indentation-sensitive : blocks, while inline parenthesized Lisp stays valid where useful. Assignment is setf (the built-in alias of =); a leading set is not special, so it remains the set constructor as in Alcove.

Adder and Alcove are one runtime and one builtin set — Adder just transpiles to Alcove S-expressions before evaluation. So every function shown in an Alcove cell is available in Adder unchanged, written in call form (f a b). Where an Alcove cell lists several builtins and the Adder cell shows only one, that is a syntax sample, not a smaller API: the same names work in Adder. The Adder column therefore highlights how the surface differs, not what is missing.

Runtime And Syntax

Topic Common Lisp Racket Clojure Emacs Lisp Alcove Adder
Typical file .lisp, .cl .rkt .clj .el .alc .adr
Run script sbcl --script file.lisp racket file.rkt clojure file.clj emacs --script file.el alcove file.alc adder file.adr when built with make als; adr.py file.adr \| alcove
REPL sbcl, implementation REPL racket clj, clojure ielm alcove adder (the Adder front end; reads .adr)
One expression implementation option such as --eval racket -e clojure -e emacs --eval alcove -e '(+ 1 2)' adder -e '+ 1 2'
Compiler implementation dependent raco make JVM bytecode via Clojure/JVM byte compiler built-in tree walker, bytecode VM, and JIT selected internally transpiles to Alcove forms before evaluation
Comments ;, block comments in most implementations ;, block comments ;, reader comment forms ; ; line comments ; line comments, and #+space to end of line. A # glued to a token is a reader literal instead: #[…] vector, #{…} set, #b"…" blob, #\c char
Separators whitespace whitespace whitespace, commas as whitespace whitespace whitespace whitespace, indentation, trailing : for blocks
Quote 'x, (quote x) same same same 'x, (quote x) 'x; emitted as (quote x)
Quasiquote backquote and comma backquote and comma syntax quote/unquote backquote and comma `(a ,b ,@xs)quasiquote/unquote/unquote-splicing via ` , ,@ `(a ,b ,@xs) — same reader forms
Booleans t, nil #t, #f true, false, nil t, nil t, nil true maps to t; false maps to nil
False values nil #f false, nil nil nil, empty list, empty string, numeric 0, empty containers nil, false, empty values
Character literal #\a #\a \a ?a #\a, #\ #\a, #\
Vector literal implementation array syntax #(...), vectors [1 2 3] [1 2 3] #[1 2 3], (vector 1 2 3) #[1 2 3] or vector 1 2 3

Names, Binding, And Assignment

Topic Common Lisp Racket Clojure Emacs Lisp Alcove Adder
Function namespace Lisp-2 Lisp-1 Lisp-1 Lisp-2 in traditional use Lisp-1 Lisp-1
Top-level/session binding defvar, defparameter, defun define def, defn setq, defun Explicit top-level/session variable binding: (setq x 3). At file/REPL top level, (= x 3) also creates/updates a top-level binding. (def f (x) …) defines a top-level function.
setq x 3        # root/session binding

setf x 3        # general assignment = (= x 3):
                # session var at top level,
                # a local inside a fn body

def f (x):
  + x 1
Local binding let, let* let, let* let let, let*, lexical-let (let x v body…) (also destructures: (let (a b) xs …)), (let* (x v y w) body…) sequential, (with (x v y w) body…) parallel
let x 10:
  + x 5

let* (x 3 y (* x 2)):   # y sees x
  + x y

with (x 3 y 4):
  sqrt (+ (* x x) (* y y))
Assignment setf, setq set! vars/atoms/refs depending on target setq, setf (= place value) updates the nearest existing lexical binding. At top level it creates/updates a session binding; inside a function an unbound symbol becomes local to that call. (setf place value) is an exact synonym of =. (setq sym value) is variable-only and falls back to a top-level session binding when no local binding exists. (set is the set-constructor, not assignment.) setf place value (or = place value) — same scope rules; setf reads better in indented code. Use setq sym value for variable assignment that falls back to a top-level session binding when no local binding exists.
Remove binding makunbound namespace mutation ns-unmap makunbound (forget ’x) removes the top-level session binding forget ’x
Persistent binding implementation-specific libraries serialize or custodian-managed state atoms/files/database libraries file variables, custom save (persist ’x), (unpersist ’x), (savedb), (loaddb) for dumpable values
persist 'x
unpersist 'x
savedb
loaddb
Symbol predicate symbolp symbol? symbol? symbolp (symbol? x) symbol? x
Function predicate functionp procedure? fn?, ifn? functionp (fn? x) fn? x

Equality, Logic, And Numbers

Topic Common Lisp Racket Clojure Emacs Lisp Alcove Adder
Identity eq, eql eq?, eqv? identical? eq (is a b); aliases eq, eq? is a b, eq a b, eq? a b
Structural equality equal, equalp equal? = equal (iso a b) iso a b
Numeric equality and assignment token = for numbers, setf for assignment = for numbers, set! for assignment = = for numbers (= place value) assigns; (iso ...) or comparisons for tests setf x v is assignment (the = alias); iso / comparisons for tests
Comparisons <, >, <=, >= same same same <, >, <=, >= chained < a b, >= a b c
Logic and, or, not and, or, not and, or, not and, or, not (and ...), (or ...), (no x) and x y, or x y, no x
Arithmetic +, -, *, /, mod +, -, *, /, modulo +, -, *, /, mod +, -, *, /, % +, -, *, /, mod + a b, - a b, * a b, / a b, mod a b
Math broad standard math library broad standard math library Java math interop common numeric functions abs, min, max, sqrt, sqrt-int, exp, expt, **, random, odd abs x, min a b, max a b, sqrt x, sqrt-int x, exp x, expt b e, random n, odd x
Bitwise logand, logior, logxor, lognot, ash bitwise library bit-and, bit-or, shifts logand, lsh bit-and/&, bit-or/|, bit-xor/^, bit-not/~, <<, >> bit-and a b, bit-or a b, bit-xor a b, bit-not a, << x n, >> x n (or the & | ^ ~ spellings)
Number tower bignums, ratios, complex numbers bignums, ratios, complex numbers JVM numeric tower integers/floats vary fixnums, floats, ratios (exact fractions), and decimals; no bignums or complex numbers runtime types unchanged; Adder only changes source spelling

Collections

Topic Common Lisp Racket Clojure Emacs Lisp Alcove Adder
List construction cons, list cons, list cons, list cons, list cons, list cons x xs, list a b c
List access car, cdr, nth car, cdr, list-ref first, rest, nth car, cdr, nth car, cdr, nth car xs, cdr xs, nth xs 0
List transforms mapcar, remove-if-not, reduce map, filter, foldl map, filter, reduce mapcar, seq-filter, cl-reduce map, filter, reduce, reverse, append, length map f xs, filter p xs, reduce f init xs, reverse xs, append a b, length xs
Sequence predicates many type predicates many type predicates seq predicates many predicates pair?, vec?, dict?, deque?, blob?, string?, number? pair? x, vec? x, dict? x, deque? x, blob? x, string? x, number? x
Fixed array/vector arrays, vectors vectors vectors vectors (vec n init), (vector ...), #[...] vec n init, vector a b c, #[...]
Vector access aref, setf vector-ref, vector-set! nth, assoc aref, aset vec-ref, vec-set!, call syntax (v i), assignment (= (v i) x) vec-ref v i, set (v i) x
Vector length length vector-length count length vec-len, length, count vec-len v, length v, count v
Vector deque window libraries libraries vectors/queues lists/ring library vec-push!, vec-pop!, vec-unshift!, vec-shift! vec-push! v x, vec-pop! v, vec-unshift! v x, vec-shift! v
Hash map (mutable) hash tables hash tables maps hash tables hash-map, assoc!, dissoc!, get, contains?, keys, vals, count; callable: (d k) is (get d k) hash-map "k" v, get d "k", d "k"
Persistent map (HAMT) FSet/immutable libs hash (immutable) maps (persistent by default) hamt, hamt-assoc, hamt-dissoc, hamt-get, hamt-count, hamt-contains?, hamt-keys, hamt-vals, hamt-merge; immutable, structural sharing; callable: (m k) is (hamt-get m k) hamt "a" 1, hamt-assoc m "b" 2, m "a"
Deque library queue queue libraries PersistentQueue, Java queues lists/ring library deque, push-right!, push-left!, pop-right!, pop-left!, peek-right, peek-left deque a b, push-right! q x, push-left! q x, pop-right! q, pop-left! q, peek-right q, peek-left q
Binary data byte arrays bytes byte arrays unibyte strings make-blob, blob-len, blob-ref, blob->string, string->blob, read-bytes; callable: (b i) is the byte at i make-blob n, read-bytes path, b i
Sets hash table conventions or libraries sets sets hash tables/libraries (set 1 2 3), set?, set-add!, set-del!, set-has?, set-union, set-intersection, set-difference, set->list; typed identity for fixnums, floats, chars, strings, symbols, blobs, nil, and t; callable: (s x) returns x if present, else nil. Prints as #{1 2 3} and re-reads in that form (as blobs print/read as #b"…") set 1 2 3 or hash-set 1 2 3 (Adder assignment is setf, so set is free to be the constructor, as in Alcove); set-has? s x, s x; same set algebra (set-union, set-intersection, set-difference, set->list)

Strings, Bytes, Regex, And Time

Topic Common Lisp Racket Clojure Emacs Lisp Alcove Adder
String predicate stringp string? string? stringp string? string? x
String length length string-length .length length length length s
Character lookup char string-ref .charAt aref (nth s i) or (s i) nth s i or (s i)
String mutation adjustable arrays / setf mutable strings Java strings immutable aset (= (s i) #\X) mutates set (s i) #\X
Concatenate concatenate string-append str concat str, string-append str a b, string-append a b
Format format format format, String/format format (fmt "{} = {:.2f}" k v){} default, {:spec} printf-style; or str for plain concatenation fmt "{} = {:.2f}" k v
Split/join libraries or sequence utilities string libraries clojure.string split-string, string-join string-split, string-join, string-trim, string-upcase, string-downcase string-split s sep, string-join xs sep, string-trim s, string-upcase s, string-downcase s
Regex CL-PPCRE or implementation libraries regexp, pregexp Java regex literals native regex functions built-in regex support (re-match, re-find, re-find-all, re-replace, re-split) same regex family
Date/time implementation time APIs time/date libraries Java time libraries time APIs (time expr) measures elapsed time; no date type time expr
Sleep implementation dependent sleep Thread/sleep sleep-for (sleep-ms n) sleep-ms n

Functions, Macros, And Control

Topic Common Lisp Racket Clojure Emacs Lisp Alcove Adder
Named function defun define defn defun Single-arity:
(def square (x) (* x x))
Multi-arity:
(defn area
  ((r) (* 3.14 r r))
  ((w h) (* w h)))
Single-arity:
def square (x):
  * x x
Multi-arity:
defn area:
  ((r) (* 3.14 r r))
  ((w h) (* w h))
Anonymous function lambda lambda fn lambda (fn (args…) body…) inline Lisp form, e.g. (fn (x) (+ x 1))
Apply apply apply apply apply apply apply f args
Map/filter/reduce mapcar, libraries map, filter, folds map, filter, reduce mapcar, seq libraries map, filter, reduce, any?, all?
map f xs
filter pred xs
reduce f init xs
Sequence body progn begin do progn do trailing : blocks naturally group body forms
Conditional if, cond, case if, cond, case if, cond, case if, cond cond-style if, when, flat case
if (< n 2):
  n
  + (fib (- n 1)) (fib (- n 2))
Loops loop, dotimes, dolist for, recursion loop, sequence ops while, dotimes, dolist while, repeat, integer for, collection each
for i 1 10:
  prn i

while test:
  body
Exceptions handler-case, restarts with-handlers try/catch condition-case Errors are reified as values, not unwinding exceptions: (try body (fn (e) …)) catches and passes the error to a handler; (error? x) and (error-message x) inspect one.
try (/ 1 0):
  fn (e):
    error-message e
Macros defmacro define-syntax family defmacro defmacro defmacro, macroexpand-1, eval macro maps to defmacro; quoted forms are ordinary data
Source and disassembly implementation dependent tools tools symbol-function, byte compiler tools source, disasm, inspect, dir, doc, help source f, disasm f, doc name, help
Escape continuation block/return-from, catch/throw call/ec, let/ec no call/cc; exceptions catch/throw (call/cc (fn (k) … (k v) …)) — one-shot, upward escape (like Scheme call/ec); k is valid only within the call/cc extent
call/cc:
  fn (k):
    + 1 (k 41)

Files, Namespaces, And Interop

Topic Common Lisp Racket Clojure Emacs Lisp Alcove Adder
Load file load require, load require, load-file load (load "file.alc") load "file.alc"
Modules/packages packages, ASDF systems modules namespaces features/provide no module system; one top-level session environment no module syntax
Streams standard stream system ports Java streams/readers buffers/processes/files built-in port/stream I/O (open, close, write, eof?, port?) same port family
Read whole file bytes read-sequence over byte array file->bytes Java/NIO helpers literal insert or unibyte strings (read-bytes "path"), read-string, read-lines, file-exists? read-bytes "path", read-string "path", read-lines "path"
Write file standard output streams ports spit, Java IO write-region write-string, append-string, write-bytes write-string path text, append-string path text, write-bytes path blob
FFI CFFI or implementation FFI Racket FFI JNI/JNA/Java interop dynamic modules/modules ffi-fn (functions), ffi-vfn (varargs, e.g. printf), ffi-callback (Alcove lambda → C fn pointer), ffi-struct/ffi-pack/ffi-unpack (struct-by-value, incl. nested) — via libffi. Native builds only. ffi-fn lib symbol ret arg..., plus ffi-vfn, ffi-callback, ffi-struct, ffi-pack, ffi-unpack (same family; native builds only)
Serialization libraries libraries EDN / libraries libraries msgpack-encode → blob, msgpack-decode → value (MessagePack): nil/t, fixnums, floats, strings/symbols, blobs, lists, string-keyed dicts; savedb/loaddb for the session store msgpack-encode v, msgpack-decode b
Java interop implementation-specific JVM variants only native JVM interop none none none
Objects CLOS classes/structs records/protocols/classes EIEIO/cl-defstruct
(defstruct point x y)
(def p (point 3 4))
(point-x p)      ; 3
(point? p)       ; t
(type-of p)      ; 'point

(defmulti area type-of)
(defmethod area 'point (p)
  (* (point-x p)
     (point-y p)))
defstruct point x y
setf p (point 3 4)
point-x p        # 3
point? p         # t
type-of p        # 'point

defmulti area type-of
defmethod area 'point (p):
  * (point-x p) (point-y p)
RESP/Redis server library territory library territory library territory library territory built-in RESP2 server and in-process Redis bridge redis-set k v, redis-get k, redis-defcmd name fn

Alcove Full Builtin Inventory

This section lists the current builtin command surface so Alcove-specific forms that do not appear in the Hyperpolyglot-style rows are still documented.

Alcove group Alcove commands Rough equivalents elsewhere
Special forms/control quote, quasiquote, if, do, when, unless, while, repeat, and, or, case, cond, match, for, each, let, let*, with CL/Racket/Clojure/Emacs all have conditionals and local binding; quasiquote/unquote/unquote-splicing match the backtick reader (`, ,, ,@); repeat, integer for, and each map to loop libraries or sequence functions; structural pattern matching (match) and flat conditional (cond)
Assignment/comparison =, setf (exact synonym of =), <, >, <=, >=, is, eq, eq?, isnt, iso, in, no, not, yes CL/Elisp setf for assignment; eq/equal families; membership functions; not/yes
Arithmetic/math +, *, -, /, mod, abs, max, min, odd, sqrt, sqrt-int, exp, expt, **, random, round, floor, ceil, truncate, log, sin, cos, tan, float, int, rational, rational?, numerator, denominator, decimal, decimal? Standard numeric functions; sqrt-int often requires a helper/library; float/int are coercions (widen / truncate); exact rationals and base-10 decimals
Bitwise bit-and, &, bit-or, |, bit-xor, ^, bit-not, ~, <<, >> CL logand/ash; Racket bitwise functions; Clojure bit functions; Emacs logand/lsh
Pairs/lists cons, car, cdr, list, length, nth, seq, first, rest, conj, into, reverse, append, take, drop, range, zip, flatten, sort, sort-by Standard list APIs; Clojure sequence operations; take/drop/ range/zip/flatten map to Racket/ Clojure sequence functions or CL subseq/loop; sort-by is Clojure's, CL's sort with a :key
Vectors vec, vector, vec-ref, vec-set!, vec-len CL arrays/vectors; Racket vectors; Clojure vectors; Emacs vectors. Vectors — like strings and blobs — are callable: (v i) reads element i (Clojure-style), the same sugar as ("abc" 0) for a char or (b 0) for a byte.
Numeric vector kernels vec-dot, vec-axpy!, vec-scale!, vec-add!, vec-copy!, vec-fill!, vec-relu!, vec-argmax, vec-max BLAS/math libraries in CL/Racket/Clojure; no common Emacs equivalent
Vector deque window vec-push!, vec-pop!, vec-unshift!, vec-shift! queue/deque libraries; Clojure persistent queues or Java deques
Functions/macros/eval def, defn, fn, defc, defmacro, macroexpand-1, eval, apply, call/cc, defstruct, defmulti, defmethod Standard Lisp function and macro facilities, with syntax differences; call/cc is an escape (upward, one-shot) continuation — like Scheme's call/ec, not a full re-entrant call/cc: the captured k is valid only within the dynamic extent of the call/cc call. defc is sugar for (def name (params) (call/cc (fn (return) body…))) — defines a function with an imperative-style early return. Struct/record types, multi-arity functions (defn), and multimethod polymorphism are also supported.
Higher order map, filter, reduce, any?, all? Sequence libraries or core functions
Predicates number?, zero?, char?, string?, symbol?, pair?, list?, null?, nil?, fn?, vec?, blob?, dict?, deque?, set? Standard type predicates; list? accepts nil or a proper list, null? tests nil; blob?, dict?, deque?, set? are Alcove-specific data types
Printing pr, print, prn, println CL princ/print/format; Racket display/write; Clojure print/println; Emacs princ/message
Persistence persist, forget, unpersist, savedb, loaddb, ispersistent No direct standard equivalent; serialize variables or use images/databases. Current dump support covers scalars, symbols, pairs/lists, lambdas/macros by source form, blobs, vectors, sets, and RESP values; dict/deque persistence is still a feature gap.
Introspection/utilities inspect, disasm, source, dir, time, web?, platform, dialect, arch, dylib-suffix, now-ms, sleep-ms, exit, quit, doc, help Implementation and target introspection tools; web? is Alcove/WASM-specific
FFI ffi-fn, ffi-vfn, ffi-callback, ffi-struct, ffi-pack, ffi-unpack CL CFFI/implementation FFI; Racket FFI; Clojure JNI/JNA; Emacs modules. ffi-vfn binds variadic C functions (e.g. printf); ffi-callback wraps an Alcove lambda as a C function pointer; ffi-struct/ffi-pack/ffi-unpack do struct-by-value (incl. nested). Native builds only — the WASM/browser build has no FFI.
Hash maps hash-map, assoc!, dissoc!, get, contains?, keys, vals, count Hash tables/maps (mutable)
Persistent maps (HAMT) hamt, hamt-assoc, hamt-get, hamt-dissoc, hamt-count, hamt-contains?, hamt-keys, hamt-vals, hamt->list, hamt-merge, hamt? Clojure persistent hash maps; Scheme/Racket immutable hashes. Immutable with structural sharing — hamt-assoc/hamt-dissoc return a new map, the original is untouched. 32-way bitmap trie; savedb round-trips it.
Serialization msgpack-encode, msgpack-decode MessagePack libraries. Round-trips nil, t, fixnums, floats, strings/symbols, blobs, lists, and string-keyed dicts; bounds-checked decode with catchable errors.
Deques deque, push-right!, push-left!, pop-right!, pop-left!, peek-left, peek-right Queue/deque libraries
Blobs make-blob, blob-len, blob-ref, blob->string, string->blob, read-bytes Byte arrays/bytes/unibyte strings
RESP bridge redis-count, redis-keys, redis-type, redis-get, redis-val, redis-set, redis-del, redis-flush, redis-port, redis-defcmd, redis-undefcmd, redis-cmds Redis client/server libraries; not a standard Lisp feature
Strings str, fmt, substr, string-append, string-concat, string-split, string-join, string-trim, string-upcase, string-downcase, string-contains?, string-index, string-replace, starts-with?, ends-with?, string-repeat, string-pad-left, string-pad-right CL concatenate/format/search; Racket/Clojure string libraries; fmt is a small {}/{:spec} templating function (printf-style specs)
Symbols/macro hygiene gensym, with-gensyms CL/Elisp gensym; with-gensyms is the common CL macro idiom (built-in here)
Error handling error?, error-message, try Errors are reified as values; try is a lightweight handler-case/with-handlers/try catching a returned error rather than unwinding
Stateful Generators *done* / *gendone*, done? / gen-done?, iter! / gen-list, range! / gen-range, next! / gen-next!, collect! / gen-collect, map! / gen-map, filter! / gen-filter, for-each! / for-gen Stateful yield-style lazy sequence generators and iterators. Preferred forms have a ! suffix (or ? for predicates) to indicate mutating state.
Clojure-Style Sequence Helpers frequencies, partition, interleave, group-by, max-by, min-by Sequence aggregation and manipulation functions.
Codecs & Serialization json-encode, json-decode, base64-encode, base64-decode, hex-encode, hex-decode Built-in data serialization and encoding formats.
TCP Networking resolve-host, tcp-connect, tcp-send, tcp-recv, tcp-close Low-level TCP client operations. Excluded from the WASM/web build.
Date & Time format-time, parse-time Time parsing and formatting helpers.
Filesystem Utilities dir-exists?, path-join, path-dirname, path-basename Cross-platform path and directory manipulation.
Programmable REPL bind-key, repl-line, repl-point, repl-end, repl-goto, repl-insert, repl-delete, repl-replace-line, repl-refresh, repl-completions API to programmatically customize shortcut keys and modify the active REPL input buffer.
Regex re-match, re-find, re-find-all, re-replace, re-split Built-in PCRE regular expression matching, search, and substitution.
File Port I/O open, close, write, eof?, port?, read-line, read-string, read-lines, write-string, append-string, write-bytes, read-bytes File and stream port I/O.

RESP Commands Implemented By Alcove

When started with -r PORT, Alcove also exposes a RESP2 server. The command set currently includes core Redis-like commands: PING, ECHO, QUIT, COMMAND, SELECT, DBSIZE, FLUSHDB, FLUSHALL, KEYS, TYPE, DEL, UNLINK, EXISTS, EXPIRE, PEXPIRE, TTL, PTTL, PERSIST, GET, SET, STRLEN, INCR, DECR, INCRBY, DECRBY, APPEND, LPUSH, RPUSH, LPOP, RPOP, LLEN, LINDEX, LRANGE, HSET, HGET, HDEL, HEXISTS, HLEN, HKEYS, HVALS, HGETALL, SAVE, and BGSAVE.

User-defined RESP commands can be registered from Lisp with redis-defcmd.