guile-devel
[Top][All Lists]
Advanced

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

Re: rfc: `process-define-module': function -> macro ?


From: Lars J. Aas
Subject: Re: rfc: `process-define-module': function -> macro ?
Date: Mon, 21 May 2001 15:17:36 +0200
User-agent: Mutt/1.2.5i

On Fri, May 18, 2001 at 10:59:02AM -0700, thi wrote:
: unfortunately, even w/ (or perhaps because of ;-) heavy caffeine dosage,
: i'm not exactly sure that i understand you.  are you saying that the
: exporting module should export also a "rename hint"?  note that in the
: current scheme, renaming is done only on import.  perhaps you mean
: something like this:
: 
: ;; file larsa/simage.scm
: (define-module (larsa simage)
:   :export (make-image image-get)
:   :rename-hint (symbol-prefix-proc 'simage:))
: (define make-image (...))
: (define image-get (...))
: => make-image image-get

":rename-hint" takes a procedure, right?, and symbol-prefix-proc returns a
closure for one?

: ;; file user1.scm
: (use-modules (larsa simage))
: => make-image image-get
: 
: ;; file user2.scm
: (use-modules (larsa simage))
: => simage:make-image simage:image-get
: 
: ;; file user3.scm
: (use-modules ((larsa simage) :rename (symbol-prefix-proc 'ZIPPY:)))
: => ZIPPY:make-image ZIPPY:image-get
: 
: ;; file user4.scm
: (use-modules ((larsa simage) :rename (symbol-prefix-proc 'ZIPPY:)))
: => ZIPPY:simage:make-image ZIPPY:simage:image-get
: 
: here, i use "=>" to mean "the current module sees these bindings".  the
: different binding sets for same input for user1/user2, and user3/user4
: demonstrate my area of confusion.

To me, user2 and user3 seems correct, while you would have to do this to
get the user1 result

(use-modules (larsa simage) : rename identity)
=> make-image image-get

However, there should be an option to do something like this:

(use-modules (larsa simage)
  :rename (lambda (sym)
           (cond
            ((prefix-is? "make-" sym)
             (concat "make-simage-" (substr sym 5)))
            (else
             (concat "simage-" sym)))))
=> make-simage-image simage-image-get

and also

(use-modules (larsa simage)
  :rename (lambda (sym)
           (cond
            ((eq? sym 'make-image) 'new-simage-image)
            (else (*default-rename* sym)))))
=> new-simage-image simage:image-get

The *default-rename* name is poor, but I couldn't think of anything better
right now.  It makes it possible to use the default scheme, but rename just
a selection of symbols.  It's probably not kosher to have *default-rename*
appear like this, so it could perhaps be a second argument to the lambda
function?

  Lars J
-- 
(list->string '(#\l #\a #\r #\s #\a #\@ #\s #\i #\m #\. #\n #\o))



reply via email to

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