[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: Namespaces for HB-Guile modules? Help. :(
From: |
Neil Jerram |
Subject: |
Re: Namespaces for HB-Guile modules? Help. :( |
Date: |
16 Nov 2001 09:21:48 +0000 |
User-agent: |
Gnus/5.0808 (Gnus v5.8.8) Emacs/20.7 |
>>>>> "Alejandro" == Alejandro Forero Cuervo <address@hidden> writes:
Alejandro> I have been working in making it possible and practical
Alejandro> to create HB modules in Guile. Once I get most of this
Alejandro> done, it will be very easy to create dynamic web
Alejandro> functionality programmed in Guile files and have HB
Alejandro> workout the rest.
Sounds fun.
Alejandro> Now lets get to my questions... There are some things
Alejandro> I don't fully understand in Guile's module system.
...
Alejandro> However, it seems that (1) modules need to be on
Alejandro> specific locations designated from them (rather than
Alejandro> wherever the users can place them, usually in the
Alejandro> public HTML tree) and (2) the programmer has to fill
Alejandro> their Guile file for a module with lots of special
Alejandro> calls to the effect of defining a new module.
It sounds like you just need to create modules dynamically rather than
through static declarations like (define-module ...).
As Rob suggests, look at `make-safe-module'; if this isn't already
enough for you, you should at least be able to see how a module can be
created dynamically.
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.
Neil
- New to Guile/Scheme, Andrew McDowell, 2001/11/14
- Re: New to Guile/Scheme, Martin Grabmueller, 2001/11/14
- Namespaces for HB-Guile modules? Help. :(, Alejandro Forero Cuervo, 2001/11/15
- Re: Namespaces for HB-Guile modules? Help. :(, Rob Browning, 2001/11/15
- Re: Namespaces for HB-Guile modules? Help. :(, Alejandro Forero Cuervo, 2001/11/22
- Re: Namespaces for HB-Guile modules? Help. :(, Neil Jerram, 2001/11/23
- Re: Namespaces for HB-Guile modules? Help. :(, Alejandro Forero Cuervo, 2001/11/23
- Re: Namespaces for HB-Guile modules? Help. :(, Marius Vollmer, 2001/11/23
- Re: Namespaces for HB-Guile modules? Help. :(,
Neil Jerram <=
- Re: Namespaces for HB-Guile modules? Help. :(, David Pirotte, 2001/11/16
- Re: Namespaces for HB-Guile modules? Help. :(, Neil Jerram, 2001/11/16
- Re: Namespaces for HB-Guile modules? Help. :(, MJ Ray, 2001/11/16
Re: New to Guile/Scheme, MJ Ray, 2001/11/14