Subject: bug#43025: re-export-public-interface fails on Guile 3

From: Dale Smith <[email-masked]>
Date: Wed, 26 Aug 2020 12:51:18 -0400

On 8/24/20, Leo Prikler <[email-masked]> wrote:
> My solution for this problem would be to build on some of the module
> "intrinsics", which sadly are not all that well documented.
>
> (define-module (a))
>
> (let ((obs (module-obarray (resolve-interface '(srfi srfi-1))))
>       (iface (module-public-interface (current-module))))
>   (hash-fold
>    (lambda (key value seed)
>      (module-add! iface key value)
>      seed)
>    *unspecified*
>    obs))
>
> If you want to make this a macro, you really only need to syntax-
> unquote a module into the (resolve-interface ...) portion of this
> snippet.

So with that in mind, how about something like this (currently no
error checking):

(define-syntax re-export-public-interface
  (syntax-rules ()
    ((_ mod ...)
     (let ((iface (module-public-interface (current-module))))
       (module-for-each
	(lambda (sym val)
	  (module-add! iface sym val)
	  (hashq-set! (module-replacements iface) sym #t))
	(resolve-interface 'mod))
       ...))))