Add a function to list procs and their docs in a module

This commit is contained in:
Vivianne 2023-12-11 00:36:55 -05:00
parent fced876ec5
commit 383d97b046
1 changed files with 14 additions and 0 deletions

14
src/reflection.scm Normal file
View File

@ -0,0 +1,14 @@
;; Example of how to fetch docs from a module.
;; This sort of pattern can be used when we want to scan a given module.
(define (pp-module-docs module)
(module-for-each
(lambda (sym var)
(let* ((binding (variable-ref var))
(proc (cond
((procedure? binding) binding)
((macro? binding) (macro-binding binding))
(else "???")))
(docs (procedure-documentation proc)))
(format #t "-- ~y ~a\n" sym docs)))
(resolve-interface module)))