diff options
author | Andy Wingo <wingo@pobox.com> | 2019-09-27 22:36:24 +0200 |
---|---|---|
committer | Andy Wingo <wingo@pobox.com> | 2019-09-27 22:57:38 +0200 |
commit | 2cca09126e8416e4b5d4be2b1edd0c9f15e0bffa (patch) | |
tree | 99a74e5f44bb7ec1ba43fe70a269cf027fcd19de | |
parent | 3e02bf72590cd2bc6d3e04555fef992bb0640a3c (diff) | |
download | guile-2cca09126e8416e4b5d4be2b1edd0c9f15e0bffa.tar.gz |
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).
-rw-r--r-- | module/ice-9/r6rs-libraries.scm | 22 |
1 files changed, 15 insertions, 7 deletions
diff --git a/module/ice-9/r6rs-libraries.scm b/module/ice-9/r6rs-libraries.scm index 579d6bd72..8ff1b4460 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 ...)))))))) |