This is the mail archive of the guile@cygnus.com mailing list for the guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: naming modules


Jim Blandy writes:

 > (Hoping to resurrect a promising topic...)
 >
 > [namespace registry and possible hierarchy]

I would prefer not to have a registry because of its huge potential for
bit-rot and goes-in-two-places problems.  However, the `(lib ...)' part
of the proposal is insightful; everyone usually produces a "library" w/
specific (and most likely disparate) organizational requirements.  So
why not just use the natural namespace partitioning mechanism (who you
are, ie domain)?  I'd agree that a module name like `(org gnu foo bar
baz)' would be heinous, but it is unambiguous, and that is really useful
for this problem.  Just requires some Emacs support to save typing.  Or,
more realistically, people will name their modules whatever they want,
which brings up the remapping requirement...

Remapping is very useful, w/ per-symbol remapping the best.  I am
thinking: many packages have some symbol called "open" or "find" or some
other generic operation name.  Someone suggested the `(import X as Y)'
syntax, which can be seen as a re-export (see below for a definition).

(define-module (X) :use-module (Y))	; w/ X "succinct" and Y "verbose"
(reexport-from-module '(Y))		; so now using X means using Y

Anyway, a remapping might look like:

(consider-module (org gnu foo bar baz)		; unspecified means direct
                 '((open . bazically-open)	;  import (like :use-module)
                   (find . bazically-locate)))
(bazically-open (bazically-find "~/.guile"))

Perhaps Per Bothner would omit the "org" and start w/ "gnu", but that's
why remapping is useful; the user can choose another view based on other
requirements.

The last argument I would advance for not having a central registry
would be the body of extant code that defies neat classification.  Hmm,
I suppose this is just the first argument repeated for old code.

In summary, it seems that the nature of glue is more emulsifier than
crystal, especially if there is a lot of glue involved.  I advocate
support for arbitrary "views" over registration of one "view".  The
latter (unfortunately) turns me off big time. :-(

thi


----------------------
;; Here is a definition for `reexport-from-module' that is used in THUD.
(define (reexport-from-module other-module-name)
  (let ((cur-mod   (current-module))
	(other-mod (resolve-module other-module-name)))
    (for-each (lambda (name)
		(module-add! (module-public-interface cur-mod)
			     name
			     (module-variable cur-mod name)))
	      (module-map (lambda (sym x)
			    sym)
			  (module-public-interface other-mod)))))