parent:
60772087cdbbe3e7543eaf73a6f0ffc9a26570c7
nmyk <nick@nmyk.io>
2026-11-14T12:31:57-05:00
lowercase and, or, not
diff --git a/DESIGN.md b/DESIGN.md
index e4cf905845eed00c38aea57d18908d2824464380..445564550383fd18ffa44706c94f46d3d1f208e7 100644
--- a/DESIGN.md
+++ b/DESIGN.md
@@ -144,9 +144,9 @@ | `quote` | special form | `GOV.0.<id>.113.117.111.116.101` | 1 operand |
| `if` | special form | `GOV.0.<id>.105.102` | 2 or 3 operands |
| `define` | special form | `GOV.0.<id>.100.101.102.105.110.101` | 2 operands |
| `lambda` | special form | `GOV.0.<id>.108.97.109.98.100.97` | params + 1 or more body forms |
-| `AND` | short-circuit form | `GOV.0.<id>.65.78.68` | 0+ operands |
-| `OR` | short-circuit form | `GOV.0.<id>.79.82` | 0+ operands |
-| `NOT` | function | `GOV.0.<id>.78.79.84` | 1 arg |
+| `and` | short-circuit form | `GOV.0.<id>.97.110.100` | 0+ operands |
+| `or` | short-circuit form | `GOV.0.<id>.111.114` | 0+ operands |
+| `not` | function | `GOV.0.<id>.110.111.116` | 1 arg |
| `+` | function | `GOV.0.<id>.43` | 0+ args |
| `-` | function | `GOV.0.<id>.45` | 1+ args |
| `*` | function | `GOV.0.<id>.42` | 0+ args |
@@ -235,9 +235,9 @@ - **`(quote d)`** returns `d` as data, unevaluated. Atoms become their values. Builtin nodes become symbols of the same name (`'+` is the symbol `+`), except `T`/`F` (booleans) and `()` (lists).
- **`(if c a b)`** evaluates `a` unless `c` is `F`, in which case it evaluates `b`. **`(if c a)`** returns `()` when `c` is `F`. Only the selected branch is evaluated.
- **`(define name expr)`** is allowed at top level and at the start of a lambda body, before any expression. It returns the symbol `name`. Scoping rules are below.
- **`(lambda (p1 … pk) body…)`** creates a closure over the current environment. It takes a fixed number of parameters (no variadic lambdas), which must be distinct symbols. The body is zero or more `define`s followed by one or more expressions; the last expression's value is returned. Calling with the wrong number of arguments is an error.
-- **`(AND x…)`** evaluates left to right and returns `F` at the first `F`; otherwise it returns the last value. `(AND)` is `T`.
-- **`(OR x…)`** evaluates left to right and returns the first value that is not `F`; otherwise `F`. `(OR)` is `F`.
-- `AND` and `OR` are special forms, so they are not first-class.
+- **`(and x…)`** evaluates left to right and returns `F` at the first `F`; otherwise it returns the last value. `(and)` is `T`.
+- **`(or x…)`** evaluates left to right and returns the first value that is not `F`; otherwise `F`. `(or)` is `F`.
+- `and` and `or` are special forms, so they are not first-class.
### Definitions and scope
@@ -261,7 +261,7 @@
- **Arithmetic.** `+` and `*` take 0+ args (`(+)` is 0, `(*)` is 1). `-` and `/` take 1+ (`(- x)` negates; `(/ x)` is `(/ 1 x)`). Int with int stays int; any float makes the result float. Integer `/` truncates toward zero. Division by zero is an error.
- **Ordering.** `<` `>` `<=` `>=` take exactly two numbers (ints and floats mix).
- **Equality.** `==` `!=` take any two values. Numbers compare numerically (`(== 1 1.0)` is `T`). Strings, symbols and booleans compare by value; pairs compare structurally. Comparing functions is an error.
-- **Boolean.** `NOT` takes one value of any type and returns T only for F.
+- **Boolean.** `not` takes one value of any type and returns T only for F.
- **Strings.** `strlen` returns the number of code points as an integer. `strcat` takes 0+ strings and returns their concatenation (`(strcat)` is `""`). `str?` takes any value and returns `T` if it is a string, else `F`. Non-string arguments to `strlen` or `strcat` are errors.
- **Lists.** `cons` takes any two values. `car` and `cdr` require a pair; `(car '())` is an error.
@@ -350,11 +350,11 @@ ((lambda (x) (define y (+ x 1)) (define z (+ y 1)) z) 1) ;=> 3
((lambda () (define a (lambda () (b))) (define b (lambda () 1)) (a))) ;=! unbound
; testdata/truthiness.lisp
-(AND F (car '())) ;=> F
-(OR F 7) ;=> 7
+(and F (car '())) ;=> F
+(or F 7) ;=> 7
(if 0 'true 'false) ;=> true
(if F 1) ;=> ()
-(NOT 0) ;=> F
+(not 0) ;=> F
; testdata/strings.lisp
(strlen "héllo") ;=> 5
diff --git a/PLAN.md b/PLAN.md
index 106beba979e8a64e5de679976705f37d12fa477c..7e18e5e788461c352b2569422b73aa35f2e3a701 100644
--- a/PLAN.md
+++ b/PLAN.md
@@ -67,7 +67,7 @@ - Build: `+ - * /` as builtin function values; int/float promotion; int64 overflow detection; truncating integer division; divide-by-zero and NaN/Inf errors.
- Learn: numeric towers; checked arithmetic (detecting overflow without wider integers); first-class builtins.
- Done when: `(+)` is `0`, `(- 5)` is `-5`, `(/ 7 2)` is `3`, `(/ 7.0 2)` is `3.5`, and `(* 9223372036854775807 2)` errors.
8. **Comparisons, lists and strings** (`eval`)
- - Build: `< > <= >= == !=`, `NOT`, `cons car cdr`, `strlen strcat str?`.
+ - Build: `< > <= >= == !=`, `not`, `cons car cdr`, `strlen strcat str?`.
- Learn: structural equality on pairs; why comparing functions is refused; strings as code points, not bytes.
- Done when: `(== '(1 2) '(1 2))` is `T`, `(== 1 1.0)` is `T`, `(strlen "héllo")` is `5`.
9. **Lambda and application** (`eval`)
@@ -78,10 +78,10 @@ 10. **Define and sequential scope** (`eval`)
- Build: `define` at top level and at the start of a lambda body; self-visible binding (a slot filled after the value is computed); rebinding in the same scope is an error.
- Learn: `let*` vs `letrec`; how self-recursion needs the name visible before the value exists, and how mutual recursion is excluded by construction.
- Done when: factorial works; `(define x (+ x 1))` errors; the design's mutual-recursion example errors as unbound.
-11. **AND / OR** (`eval`)
+11. **and / or** (`eval`)
- Build: short-circuit special forms returning values (Scheme style).
- Learn: why short-circuiting forces these to be special forms rather than functions.
- - Done when: `(OR F 7)` is `7` and `(AND F (car '()))` is `F` without error.
+ - Done when: `(or F 7)` is `7` and `(and F (car '()))` is `F` without error.
12. **Tail calls** (`eval`)
- Build: rewrite `Eval` as a loop that continues in place for `if` branches and closure bodies (a trampoline).
- Learn: proper tail calls; why a naive recursive evaluator overflows the Go stack.
diff --git a/eval/builtin.go b/eval/builtin.go
index bb1a55aee2cdf84b9e012870c821d0e5975fa99f..5d0f3dab1ea0e9469446f3f3168393842ab0435a 100644
--- a/eval/builtin.go
+++ b/eval/builtin.go
@@ -31,7 +31,7 @@ {name: "<=", minArgs: 2, maxArgs: 2, fn: lessEq},
{name: ">=", minArgs: 2, maxArgs: 2, fn: greaterEq},
{name: "==", minArgs: 2, maxArgs: 2, fn: equal},
{name: "!=", minArgs: 2, maxArgs: 2, fn: notEqual},
- {name: "NOT", minArgs: 1, maxArgs: 1, fn: not},
+ {name: "not", minArgs: 1, maxArgs: 1, fn: not},
{name: "cons", minArgs: 2, maxArgs: 2, fn: cons},
{name: "car", minArgs: 1, maxArgs: 1, fn: car},
{name: "cdr", minArgs: 1, maxArgs: 1, fn: cdr},
diff --git a/eval/compare_test.go b/eval/compare_test.go
index 38839d833a7645711f2e679ba94d04e5b79518ed..be695e0d30fdf989b511fd0ef09f75d16eea0897 100644
--- a/eval/compare_test.go
+++ b/eval/compare_test.go
@@ -66,13 +66,13 @@ {"(== '(a) 'a)", "F"},
{"(!= '(1 2) '(1 2))", "F"},
// Only F is false.
- {"(NOT F)", "T"},
- {"(NOT T)", "F"},
- {"(NOT 0)", "F"},
- {"(NOT ())", "F"},
- {`(NOT "")`, "F"},
- {"(NOT (NOT F))", "F"},
- {"(NOT (< 2 1))", "T"},
+ {"(not F)", "T"},
+ {"(not T)", "F"},
+ {"(not 0)", "F"},
+ {"(not ())", "F"},
+ {`(not "")`, "F"},
+ {"(not (not F))", "F"},
+ {"(not (< 2 1))", "T"},
})
}
@@ -81,8 +81,8 @@ runErrorCases(t, []errorCase{
{"(< 1)", ErrArity, "< takes 2 arguments, got 1"},
{"(< 1 2 3)", ErrArity, "< takes 2 arguments, got 3"},
{"(==)", ErrArity, "== takes 2 arguments, got 0"},
- {"(NOT)", ErrArity, "NOT takes 1 argument, got 0"},
- {"(NOT T F)", ErrArity, "NOT takes 1 argument, got 2"},
+ {"(not)", ErrArity, "not takes 1 argument, got 0"},
+ {"(not T F)", ErrArity, "not takes 1 argument, got 2"},
{`(< "a" "b")`, ErrType, `argument 1 of < must be a number, got "a"`},
{"(>= 1 'x)", ErrType, "argument 2 of >= must be a number, got x"},
{"(< 1 ())", ErrType, "argument 2 of < must be a number, got ()"},