guile-user
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Namespaces for HB-Guile modules? Help. :(


From: David Pirotte
Subject: Re: Namespaces for HB-Guile modules? Help. :(
Date: Fri, 16 Nov 2001 12:50:26 +0100

Neil Jerram wrote:
> Another possibly helpful example is what I do in my Elisp translator
> to set up a dynamically named module:
> 
> (define-macro (use-elisp-file file-name . imports)
>   "Load Elisp code file @var{file-name} and import its definitions
> into the current Scheme module.  If any @var{imports} are specified,
> they are interpreted as selection and renaming specifiers as per
> @code{use-modules}."
>   (let ((export-module-name (export-module-name)))
>     `(begin
>        (fluid-set! ,elisp-export-module (resolve-module ',export-module-name))
>        (beautify-user-module! (resolve-module ',export-module-name))
>        (load-elisp-file ,file-name)
>        (use-modules (,export-module-name ,@imports))
>        (fluid-set! ,elisp-export-module #f))))
> 
> The key bits here are
> - construct the module name dynamically however you like, to result in
>   a list of symbols
> - use `resolve-module' to turn this into a module object
> - use `beautify-user-module!' on the module object to ... err ... I
>   forget, but it was necessary for my purposes.
> 
> Having done this, you could do
> 
> (save-module-excursion (lambda ()
>                          (set-current-module MODULE)
>                          (load "whatever.guile")))
> 
> to load "whatever.guile" into that module, or you could just use
> `module-define!', `module-set!' and so on to put bindings into the
> module one by one.

Couldn't we have this as a standard feature of the guile module system?



reply via email to

[Prev in Thread] Current Thread [Next in Thread]