Files
rose-ash/lib/r7rs.sx
giles 3c419501e1 Fix r7rs.sx: remove guard macro (transpiler blocker), fix null?/boolean=?
guard macro expansion loops in the transpiled evaluator because
expand_macro→eval_expr→CEK can't handle let+first/rest in macro
bodies. Removed guard macro; will re-add as special form once
transpiler handles runtime AST construction (cons/append/make-symbol).

Fixed null? to handle empty lists (not just nil).
Fixed boolean=? to use = instead of undefined eq?.

2561/2568 tests pass (37 new vs baseline, 5 guard + 2 scope pending).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-04-03 10:20:31 +00:00

54 lines
1.2 KiB
Plaintext

(define make-error-object (fn (message irritants) {:irritants irritants :type "error-object" :message message}))
(define
error-object?
(fn (x) (and (dict? x) (= (get x "type") "error-object"))))
(define
error-message
(fn (x) (if (error-object? x) (get x "message") (str x))))
(define
error-object-irritants
(fn (x) (if (error-object? x) (get x "irritants") (list))))
(defmacro
with-exception-handler
(handler thunk)
(quasiquote
(handler-bind (((fn (c) true) (unquote handler))) ((unquote thunk)))))
(define car first)
(define cdr rest)
(define cadr (fn (x) (first (rest x))))
(define cddr (fn (x) (rest (rest x))))
(define caar (fn (x) (first (first x))))
(define cdar (fn (x) (rest (first x))))
(define caddr (fn (x) (first (rest (rest x)))))
(define cadddr (fn (x) (first (rest (rest (rest x))))))
(define null? (fn (x) (or (nil? x) (and (list? x) (empty? x)))))
(define pair? (fn (x) (and (list? x) (not (empty? x)))))
(define procedure? (fn (x) (or (lambda? x) (callable? x))))
(define boolean=? (fn (a b) (= a b)))
(define symbol->string symbol-name)
(define string->symbol make-symbol)
(define number->string (fn (n) (str n)))
(define
string->number
(fn (s) (if (string-contains? s ".") (parse-float s) (parse-int s))))