guile-commits
[Top][All Lists]
Advanced

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

[Guile-commits] 09/09: Extend `import' to allow R7RS-style srfi referenc


From: Andy Wingo
Subject: [Guile-commits] 09/09: Extend `import' to allow R7RS-style srfi references
Date: Fri, 27 Sep 2019 17:15:55 -0400 (EDT)

wingo pushed a commit to branch master
in repository guile.

commit 2cca09126e8416e4b5d4be2b1edd0c9f15e0bffa
Author: Andy Wingo <address@hidden>
Date:   Fri Sep 27 22:36:24 2019 +0200

    Extend `import' to allow R7RS-style srfi references
    
    * module/ice-9/r6rs-libraries.scm (resolve-r6rs-interface): Allow for
      srfis to be accessed via (srfi 42 foo) in addition to (srfi :42 foo).
---
 module/ice-9/r6rs-libraries.scm | 22 +++++++++++++++-------
 1 file changed, 15 insertions(+), 7 deletions(-)

diff --git a/module/ice-9/r6rs-libraries.scm b/module/ice-9/r6rs-libraries.scm
index 579d6bd..8ff1b44 100644
--- a/module/ice-9/r6rs-libraries.scm
+++ b/module/ice-9/r6rs-libraries.scm
@@ -1,6 +1,6 @@
 ;;; r6rs-libraries.scm --- Support for the R6RS `library' and `import' forms
 
-;;      Copyright (C) 2010 Free Software Foundation, Inc.
+;;      Copyright (C) 2010, 2019 Free Software Foundation, Inc.
 ;;
 ;; This library is free software; you can redistribute it and/or
 ;; modify it under the terms of the GNU Lesser General Public
@@ -41,21 +41,29 @@
 
   (syntax-case import-spec (library only except prefix rename srfi)
     ;; (srfi :n ...) -> (srfi srfi-n ...)
-    ((library (srfi colon-n rest ... (version ...)))
+    ;; (srfi n ...) -> (srfi srfi-n ...)
+    ((library (srfi n rest ... (version ...)))
      (and (and-map sym? #'(srfi rest ...))
-          (symbol? (syntax->datum #'colon-n))
-          (eqv? (string-ref (symbol->string (syntax->datum #'colon-n)) 0) #\:))
+          (or (and
+               (symbol? (syntax->datum #'n))
+               (let ((str (symbol->string (syntax->datum #'n))))
+                 (and (string-prefix? ":" str)
+                      (and=> (string->number (substring str 1))
+                             exact-integer?))))
+              (exact-integer? (syntax->datum #'n))))
      (let ((srfi-n (string->symbol
                     (string-append
                      "srfi-"
-                     (substring (symbol->string (syntax->datum #'colon-n))
-                                1)))))
+                     (let ((n (syntax->datum #'n)))
+                       (if (symbol? n)
+                           (substring (symbol->string n) 1)
+                           (number->string n)))))))
        (resolve-r6rs-interface
         (syntax-case #'(rest ...) ()
           (()
            #`(library (srfi #,srfi-n (version ...))))
           ((name rest ...)
-           ;; SRFI 97 says that the first identifier after the colon-n
+           ;; SRFI 97 says that the first identifier after the `n'
            ;; is used for the libraries name, so it must be ignored.
            #`(library (srfi #,srfi-n rest ... (version ...))))))))
     



reply via email to

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