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

@@ -9,6 +9,16 @@
(pub var greet-count int 0)
(pub struct greeting ((text (* const char)) (times int)))
;;; Compile-time reflection across the module boundary: both the macro
;;; and the struct it asks about are exported, and the importing unit
;;; has to know the struct's fields to expand this.
(pub defmacro (describe-fields type)
`(do ,@(map-fields type
(lambda (name field-type)
`(printf "%s " ,(symbol->string name))))))
(pub fn greet ((name (* const char))) void
(++ greet-count)
(printf "hello, %s\n" name))