process imported forms as toplevel, not as text

1. register imported types
2. protect against multiple imports (diamond, circular)
This commit is contained in:
2026-09-16 01:11:53 +03:00
parent 85bf1c163c
commit d0d0ea8e84
5 changed files with 32 additions and 13 deletions

View File

@@ -14,6 +14,10 @@
(define +persistent-module-paths+ (list))
;;; for guarding against multiple imports (sort of mandatory #pragma
;;; once)
(define +imported-modules+ (list))
(define (get-modules-public-forms module-list)
;; Module list is a list of symbols
;; How Sex handles modules:
@@ -29,7 +33,11 @@
(let ((module-path (locate-module name)))
(assert module-path (fmt #f "Failed to find module " name " in "
(get-module-paths)))
(read-public-interface module-path)))
(if (member module-path +imported-modules+)
(list)
(begin
(set! +imported-modules+ (cons module-path +imported-modules+))
(read-public-interface module-path)))))
(define (get-module-paths)
(cons (current-directory)