Fix macro expansion #9

Merged
alex-eg merged 3 commits from fix-macro-expansion into main 2025-09-29 14:56:51 +02:00
Showing only changes of commit 9833e12777 - Show all commits

View File

@@ -79,6 +79,23 @@
(cons (car module-public-forms) (cons (car module-public-forms)
pkulev commented 2025-09-29 14:29:26 +02:00 (Migrated from github.com)
Review
  "Walk the form recursively and expand all macros, until none is left."
```suggestion "Walk the form recursively and expand all macros, until none is left." ```
acc)))))) acc))))))
;;; TODO: for greater inspiration, see SBCL's walk.lisp
(define (semen-walk-form form walk-fn)
(if (atom? form) form
(let ((new-form (walk-fn form)))
(cond ((not (eq? form new-form))
(semen-walk-form new-form walk-fn))
(else (recons
new-form
(semen-walk-form (car new-form) walk-fn)
(semen-walk-form (cdr new-form) walk-fn)))))))
(define (recons old-cons new-car new-cdr)
(if (and (eq? new-car (car old-cons))
(eq? new-cdr (cdr old-cons)))
old-cons
(cons new-car new-cdr)))
(define (process-fn sex-fn acc) (define (process-fn sex-fn acc)
(cons sex-fn acc)) (cons sex-fn acc))