Peter Brett <pe...@peter-b.co.uk> writes: > l...@gnu.org (Ludovic Courtès) writes:
[...] >> Then you are looking for Guile's nifty first-class modules. The module >> API is unfortunately lightly documented (info "(guile) Module System >> Reflection"). > > Indeed. Should I file a feature request for "more useful > documentation of the Guile module system"? You can indeed at this to the bug tracker at http://savannah.gnu.org/bugs/?group=guile, preferably along with a patch. :-) [...] > How much will the way they work be changing in the next stable series > of Guile releases? There should not be any user-visible changes (you can already try out the 1.9 releases to see by yourself). > How will they work w.r.t. R6RS modules? It's unclear whether R6RS module support will be part of the forthcoming 2.0 release series; Julian Graham is working on it, though. >> What you would do is create one module for each file/project/directory: >> >> (define (make-per-file-module name) >> (let ((m (make-module))) >> (set-module-name! m name) ;; give the module an optional name >> (beautify-user-module! m) ;; populate the module with the >> ;; default bindings >> m)) > > Something like the following? > > SCM > create_module_for_dir (char *c_path) /* Path is a UTF-8 string */ > { > SCM magic = scm_from_locale_symbol ("*magic-dir-module*"); > SCM path = scm_from_locale_symbol (c_path); > SCM module = scm_resolve_module (scm_list_2 (magic, path)); > scm_remember_upto_here_2 (magic, path); > return module; > } > > Not entirely sure how to emulate "beautify-user-module!" in C... any ideas? `resolve-module' returns a new empty module (as with `make-module') if no module of that name exist, so you really need the effect of `beautify-user-module!'. The best way is to invoke it: SCM beautify = scm_c_lookup ("beautify-user-module!"); scm_call_1 (beautify, module); Thanks, Ludo'.