Keep a 2.0.0-compatible `define-inlinable' macro in (srfi srfi-9).
authorLudovic Courtès <ludo@gnu.org>
Wed, 27 Apr 2011 20:26:05 +0000 (22:26 +0200)
committerLudovic Courtès <ludo@gnu.org>
Wed, 27 Apr 2011 20:26:05 +0000 (22:26 +0200)
Partially reverts 165b10ddfaaa8ecc72d45a9be7d29e7537dc2379 and
531c9f1dc51c4801c4d031ee80a31f15285a6b85.

* module/srfi/srfi-9.scm (define-inlinable): New macro.

module/srfi/srfi-9.scm

index ad9e95d..6574a8d 100644 (file)
 
 (cond-expand-provide (current-module) '(srfi-9))
 
+;; Roll our own instead of using the public `define-inlinable'.  This is
+;; because the public one has a different `make-procedure-name', so
+;; using it would require users to recompile code that uses SRFI-9.  See
+;; <http://lists.gnu.org/archive/html/guile-devel/2011-04/msg00111.html>.
+
+(define-syntax define-inlinable
+  (lambda (x)
+    (define (make-procedure-name name)
+      (datum->syntax name
+                     (symbol-append '% (syntax->datum name)
+                                    '-procedure)))
+
+    (syntax-case x ()
+      ((_ (name formals ...) body ...)
+       (identifier? #'name)
+       (with-syntax ((proc-name  (make-procedure-name #'name))
+                     ((args ...) (generate-temporaries #'(formals ...))))
+         #`(begin
+             (define (proc-name formals ...)
+               body ...)
+             (define-syntax name
+               (lambda (x)
+                 (syntax-case x ()
+                   ((_ args ...)
+                    #'((lambda (formals ...)
+                         body ...)
+                       args ...))
+                   (_
+                    (identifier? x)
+                    #'proc-name))))))))))
+
 (define-syntax define-record-type
   (lambda (x)
     (define (field-identifiers field-specs)