wingo pushed a commit to branch wip-whippet
in repository guile.

commit 110eafcafea46d75b72705e495606ee6595db685
Author: Andy Wingo <wi...@pobox.com>
AuthorDate: Mon Jun 16 11:59:52 2025 +0200

    Deprecate module-defined-hook
    
    Instead there is a module-definition-observer parameter.
    
    * module/ice-9/boot-9.scm (module-definition-observer): New param.
    * module/ice-9/deprecated.scm (module-defined-hook): Add deprecated
    definition; install as definition observer.
---
 module/ice-9/boot-9.scm     |  9 +++------
 module/ice-9/deprecated.scm | 10 +++++++++-
 2 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index 65a1fe915..096a644f5 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -3390,13 +3390,10 @@ error if selected binding does not exist in the used 
module."
       (set-module-inlinable-exports! (module-public-interface module)
                                      inlinable-exports))
 
-    (run-hook module-defined-hook module)
-    module))
+    ((module-definition-observer) module)))
 
-;; `module-defined-hook' is a hook that is run whenever a new module
-;; is defined.  Its members are called with one argument, the new
-;; module.
-(define module-defined-hook (make-hook 1))
+(define module-definition-observer
+  (make-parameter (lambda (m) m)))
 
 
 
diff --git a/module/ice-9/deprecated.scm b/module/ice-9/deprecated.scm
index 848258b7d..f585664bf 100644
--- a/module/ice-9/deprecated.scm
+++ b/module/ice-9/deprecated.scm
@@ -124,7 +124,8 @@
             (before-print-hook* . before-print-hook)
             (after-print-hook* . after-print-hook)
             (exit-hook* . exit-hook)
-            (repl-reader* . repl-reader)))
+            (repl-reader* . repl-reader)
+            module-defined-hook))
 
 (define-syntax define-deprecated/stx
   (lambda (stx)
@@ -343,3 +344,10 @@
   abort-hook
   before-backtrace-hook
   after-backtrace-hook)
+
+(define module-defined-hook (make-hook 1))
+(let ((prev (module-definition-observer)))
+  (module-definition-observer
+   (lambda (m)
+     (run-hook module-defined-hook m)
+     (prev m))))

Reply via email to