guile-user
[Top][All Lists]
Advanced

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

Re: removing #:renamer


From: Thien-Thi Nguyen
Subject: Re: removing #:renamer
Date: Sun, 14 Feb 2010 23:52:29 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.1.91 (gnu/linux)

() address@hidden (Ludovic Courtès)
() Sun, 14 Feb 2010 22:45:02 +0100

   Hmm, the philosophy would also say “don’t remove anything that
   wasn’t deprecated in the previous major series and that doesn’t
   *strictly* need to be removed”.

I tend to look at it as a misfeature at best (overly general) and
think if no one is using it, the question is when best to remove
it.  If we keep this wart for 2.0, it will not be until 3.0 that
we can remove it, during which time no one will benefit from it
and we will have to maintain it.

   IOW, I’m in favor of keeping #:renamer in 2.0.

For what *actual* use?  (I can see one pedagogical use: it would
be a constant reminder for me not to add stuff w/o more thought in
the future... :-)

   (Actually I didn’t know about #:prefix.  It’s undocumented, but
   dates back to 2003 AFAICS.  #:renamer is undocumented too, but
   at least there’s one example in the manual.  ;-))

I don't know why you say :renamer is undocumented.  Have you
tried (info "(guile) Using Guile Modules") ?  BTW, below is a
diff of that node's reworked .texi (local wip).  I will be pushing
the branch its on for review sometime tomorrow, after i get some
practice in my git sandbox...

thi

________________________________________________________________________
diff --git a/doc/ref/api-modules.texi b/doc/ref/api-modules.texi
index a717386..c21bf19 100644
--- a/doc/ref/api-modules.texi
+++ b/doc/ref/api-modules.texi
@@ -251,11 +251,11 @@ @node Using Guile Modules
 module to be accessed, but also selects bindings from it and renames
 them to suit the current module's needs.  For example:
 
address@hidden binding renamer
address@hidden binding prefixer
 @lisp
 (use-modules ((ice-9 popen)
               #:select ((open-pipe . pipe-open) close-pipe)
-              #:renamer (symbol-prefix-proc 'unixy:)))
+              #:prefix unixy:))
 @end lisp
 
 Here, the interface specification is more complex than before, and the
@@ -270,9 +270,6 @@ @node Using Guile Modules
 close-pipe                      unixy:close-pipe
 @end smallexample
 
-This example also shows how to use the convenience procedure
address@hidden
-
 You can also directly refer to bindings in a module by using the
 @code{@@} syntax.  For example, instead of using the
 @code{use-modules} statement from above and writing
@@ -303,7 +300,14 @@ @node Using Guile Modules
 @deffn {Scheme Procedure} symbol-prefix-proc prefix-sym
 Return a procedure that prefixes its arg (a symbol) with
 @var{prefix-sym}.
address@hidden Insert gratuitous C++ slam here.  --ttn
+This procedure was useful with the @code{:renamer} clause supported
+in previous Guile releases (removed as of Guile 2.0).  You can achieve
+identical results with @code{#:prefix}, now.
+
address@hidden
+was: #:use-module (FOO #:renamer (symbol-prefix-proc 'BAR))
+now: #:use-module (FOO #:prefix BAR)
address@hidden smallexample
 @end deffn
 
 @c begin (scm-doc-string "boot-9.scm" "use-modules")
@@ -317,9 +321,9 @@ @node Using Guile Modules
 
 @var{spec} can also be of the form:
 
address@hidden binding renamer
address@hidden binding prefixer
 @lisp
- (MODULE-NAME [:select SELECTION] [:renamer RENAMER])
+ (MODULE-NAME [:select SELECTION] [:prefix SYMBOL])
 @end lisp
 
 in which case a custom interface is newly created and used.
@@ -330,9 +334,9 @@ @node Using Guile Modules
 the used module and @var{seen} is the name in the using module.  Note
 that @var{seen} is also passed through @var{renamer}.
 
-The @code{:select} and @code{:renamer} clauses are optional.  If both are
+The @code{:select} and @code{:prefix} clauses are optional.  If both are
 omitted, the returned interface has no bindings.  If the @code{:select}
-clause is omitted, @var{renamer} operates on the used module's public
+clause is omitted, @var{:prefix} operates on the used module's public
 interface.
 
 In addition to the above, @var{spec} can also include a @code{:version} 
diff --git a/examples/modules/main b/examples/modules/main
index e4cc71d..ef8c2ae 100644
--- a/examples/modules/main
+++ b/examples/modules/main
@@ -22,14 +22,14 @@
   ;; Module 1 is imported completely, too, but the procedure names are
   ;; prefixed with the module name.
   ;;
-  :use-module ((module-1) :renamer (symbol-prefix-proc 'module-1:))
+  :use-module ((module-1) :prefix module-1:)
 
   ;; From module 2, only the procedure `braz' is imported, so that the
   ;; procedures `foo' and `bar' also exported by that module don't
   ;; clash with the definitions of module 0.
   ;;
   :use-module ((module-2) :select (braz))
-  
+
   ;; Import the bindings from module 2 again, now renaming them by
   ;; explicitly mentioning the original and new names.
   ;;
diff --git a/module/ice-9/boot-9.scm b/module/ice-9/boot-9.scm
index af09be8..910ecdf 100644
--- a/module/ice-9/boot-9.scm
+++ b/module/ice-9/boot-9.scm
@@ -2135,11 +2135,6 @@ (define (purify-module! module)
 ;; PREFIX is a symbol that will be appended to each exported name.
 ;; The default is to not perform any renaming.
 ;;
-;;   #:renamer RENAMER
-;;
-;; RENAMER is a procedure that takes a symbol and returns its new
-;; name.  The default is not perform any renaming.
-;;
 ;; Signal "no code for module" error if module name is not resolvable
 ;; or its public interface is not available.  Signal "no binding"
 ;; error if selected binding does not exist in the used module.
@@ -2157,8 +2152,7 @@ (define (resolve-interface name . args)
 
   (let* ((select (get-keyword-arg args #:select #f))
          (hide (get-keyword-arg args #:hide '()))
-         (renamer (or (get-keyword-arg args #:renamer #f)
-                      (let ((prefix (get-keyword-arg args #:prefix #f)))
+         (renamer (or (let ((prefix (get-keyword-arg args #:prefix #f)))
                         (and prefix (symbol-prefix-proc prefix)))
                       identity))
          (version (get-keyword-arg args #:version #f))
@@ -2964,7 +2958,6 @@ (define (compile-interface-spec spec)
     '((:select #:select #t)
       (:hide   #:hide   #t)
       (:prefix #:prefix #t)
-      (:renamer #:renamer #f)
       (:version #:version #t)))
   (if (not (pair? (car spec)))
       `(',spec)




reply via email to

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