Add self-hosted standard library (and, or, cond, when, let*) #61

Open
opened 2026-02-07 17:11:32 +00:00 by navicore · 0 comments
navicore commented 2026-02-07 17:11:32 +00:00 (Migrated from github.com)

Summary

Create a self-hosted standard library that defines common forms as macros in SeqLisp itself, following seq-lisp-2's minimal-kernel philosophy.

Motivation

During the LSP document symbols work, we discovered that or is not a builtin — we had to write verbose nested if chains like:

(define (whitespace? ch)
  (if (equal? ch " ") #t
    (if (equal? ch "\n") #t
      (if (equal? ch "\t") #t
        (equal? ch "\r")))))

With a self-hosted stdlib, this becomes:

(define (whitespace? ch)
  (or (equal? ch " ") (equal? ch "\n") (equal? ch "\t") (equal? ch "\r")))

seq-lisp-2's design philosophy is a minimal Seq kernel with higher-level forms defined in Lisp. This is elegant — fewer Seq builtins to maintain, and users can read/modify the standard library.

Proposed Forms

(defmacro and (a b) (list 'if a b #f))
(defmacro or (a b) (list 'if a #t b))
(defmacro when (test body) (list 'if test body #f))
(defmacro unless (test body) (list 'if test #f body))

Future additions could include let*, variadic and/or, case, etc.

Scope

  • Create lib/stdlib.slisp with core macros
  • Load stdlib automatically before user code (or as a prelude)
  • Ensure LSP server loads stdlib
  • Add tests for all stdlib forms
  • Document the stdlib

Notes

This is the highest-value, lowest-risk idea from seq-lisp-2. It directly addresses pain points and doesn't require touching the Seq evaluator.

Inspired by seq-lisp-2's stated goals for self-hosted let, cond, and, or, map, filter, fold.

## Summary Create a self-hosted standard library that defines common forms as macros in SeqLisp itself, following seq-lisp-2's minimal-kernel philosophy. ## Motivation During the LSP document symbols work, we discovered that `or` is not a builtin — we had to write verbose nested `if` chains like: ```lisp (define (whitespace? ch) (if (equal? ch " ") #t (if (equal? ch "\n") #t (if (equal? ch "\t") #t (equal? ch "\r"))))) ``` With a self-hosted stdlib, this becomes: ```lisp (define (whitespace? ch) (or (equal? ch " ") (equal? ch "\n") (equal? ch "\t") (equal? ch "\r"))) ``` seq-lisp-2's design philosophy is a minimal Seq kernel with higher-level forms defined in Lisp. This is elegant — fewer Seq builtins to maintain, and users can read/modify the standard library. ## Proposed Forms ```lisp (defmacro and (a b) (list 'if a b #f)) (defmacro or (a b) (list 'if a #t b)) (defmacro when (test body) (list 'if test body #f)) (defmacro unless (test body) (list 'if test #f body)) ``` Future additions could include `let*`, variadic `and`/`or`, `case`, etc. ## Scope - Create `lib/stdlib.slisp` with core macros - Load stdlib automatically before user code (or as a prelude) - Ensure LSP server loads stdlib - Add tests for all stdlib forms - Document the stdlib ## Notes This is the highest-value, lowest-risk idea from seq-lisp-2. It directly addresses pain points and doesn't require touching the Seq evaluator. Inspired by seq-lisp-2's stated goals for self-hosted `let`, `cond`, `and`, `or`, `map`, `filter`, `fold`.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
navicore/seq-lisp#61
No description provided.