guile-devel
[Top][All Lists]
Advanced

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

Re: Module name == dir hierarchy seems to make devel awkward...


From: Michael Livshin
Subject: Re: Module name == dir hierarchy seems to make devel awkward...
Date: 23 Mar 2001 18:32:03 +0200
User-agent: Gnus/5.0807 (Gnus v5.8.7) XEmacs/21.1 (Crater Lake)

Rob Browning <address@hidden> writes:

> Wait a minute.  I just thought of something that might work fairly
> well if it's not considered too kludgy.  I wonder if we could add
> something like a module mapping registry to guile.  It would normally
> be empty, and so in the standard case, modules would just work the way
> they always have, where you search %load-path until you find the right
> file in the right relative place, but we'd also have a mechanism by
> which you can say:
> 
>   (set-module-to-path-mapping! '(foo bar baz) "./baz.scm")
> 
> and this setting would be consulted first, before trying the normal
> search mechanism.  In the general case, you'd never use this mapping,
> but when you're developing, you could use it to avoid the deep empty
> hierarchies.
> 
> Not sure it's a great idea, but it's an idea :>

hey, nice wheel! ;)

I can think of two older wheels that could be used instead:

1) if you look closely, you'll see that you've just described a
   generic protocol.  so here is some pseudo code:

;;; module names are kind of lists of symbols, but "interned",
;;; i.e.:
;;; (eq? (module-name '(foo bar baz))
;;;      (module-name '(foo bar baz))) => #t
(define-class <module-name> ...)

(define module-name
  (let ((table (make-hash-table)))
    (lambda (list-of-symbols)
      (or (hash-lookup table list-of-symbols)
          (let ((p (make <module-name> #:list list-of-symbols)))
            (hash-insert table list-of-symbols p)
            p)))))

(define-generic get-module-path)

(define-method (get-module-path (name <module-name>))
  ;; the usual thing
  ...)

now, to "pin" down some module, you'd say:

(define-method (get-module-path (name (eql (module-name '(foo bar baz)))))
  "./baz.scm")

this does assume that GOOPS supports eql-specializers.  I don't know
if it does...

2) the above wheel is nice, but not versatile enough.  what if you
   want to pin down a whole sub-hierarchy of modules?

I think we should snarf the whole path-translation mechanism from
Common Lisp.  or maybe implement something equivalent with a nicer
syntax.  the PLT guys have something like this, I believe, so it would
be instructive to look there.

--mike, as always full of hot air.

-- 
All ITS machines now have hardware for a new machine instruction --
BOT
Branch On Tree.
Please update your programs.




reply via email to

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