* [PATCH] Transform R6RS SRFI module name on definition.
@ 2015-10-02 21:45 Taylan Ulrich Bayırlı/Kammer
2015-12-03 9:05 ` Taylan Ulrich Bayırlı/Kammer
0 siblings, 1 reply; 3+ messages in thread
From: Taylan Ulrich Bayırlı/Kammer @ 2015-10-02 21:45 UTC (permalink / raw)
To: guile-devel
[-- Attachment #1: Type: text/plain, Size: 1615 bytes --]
Currently our R6RS 'import' form automatically transforms an import like
(srfi :n ...) to (srfi srfi-n ...).
This works fine with the SRFIs that ship with Guile and any extra SRFI
modules defined with the verbose name format (srfi srfi-n ...).
However, when one really defines a library named (srfi :n ...), then
'import' fails to find this because it only looks for the verbose name.
Here a transcript showcasing the issue:
--- snip ---
scheme@(guile-user)> (library (srfi :200) (export test) (import (rnrs base)) (define test 'test))
scheme@(srfi :200)> ,m guile-user
scheme@(guile-user)> (import (srfi :200))
While compiling expression:
ERROR: no code for module (srfi srfi-200)
scheme@(guile-user)> ,use (srfi :200)
scheme@(guile-user)> test
$2 = test
scheme@(guile-user)>
--- snip ---
(Use-modules actually finds it, as you see.)
The attached patch makes our R6RS 'library' form automatically transform
a library name like (srfi :n ...) to (srfi srfi-n ...).
Will this leak out to the user in such a way that it breaks conformance
or creates problems? Is it bad that this time 'use-modules' won't be
able to find (srfi :n ...)? I don't think it is; users should just use
(srfi :n ...) with 'import' and (srfi srfi-n ...) with 'use-modules'.
Note that it's actually not 'import' itself that does the reverse
transform but a deeper part of the system, and thus for instance the
'environment' form from (rnrs eval) also correctly resolves the module
name (srfi :n ...) to (srfi srfi-n ...). If there are any "holes" left
where the transform doesn't happen, we should be able to plug those too.
WDYT?
[-- Attachment #2: 0001-Transform-R6RS-SRFI-module-names-on-definition.patch --]
[-- Type: text/x-diff, Size: 2110 bytes --]
From 952870469d852ca910558810de1c853124abd830 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
<taylanbayirli@gmail.com>
Date: Fri, 2 Oct 2015 23:29:08 +0200
Subject: [PATCH] Transform R6RS SRFI module names on definition.
* module/ice-9/r6rs-libraries.scm (library): Transform the names of
defined SRFI modules from (srfi :n ...) to (srfi srfi-n ...).
---
module/ice-9/r6rs-libraries.scm | 20 ++++++++++++++++++--
1 file changed, 18 insertions(+), 2 deletions(-)
diff --git a/module/ice-9/r6rs-libraries.scm b/module/ice-9/r6rs-libraries.scm
index a68df3c..a7e7da7 100644
--- a/module/ice-9/r6rs-libraries.scm
+++ b/module/ice-9/r6rs-libraries.scm
@@ -1,6 +1,7 @@
;;; r6rs-libraries.scm --- Support for the R6RS `library' and `import' forms
-;; Copyright (C) 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2010 Free Software Foundation, Inc.
+;; Copyright (C) 2015 Taylan Ulrich Bayırlı/Kammer <taylanbayirli@gmail.com>
;;
;; This library is free software; you can redistribute it and/or
;; modify it under the terms of the GNU Lesser General Public
@@ -158,7 +159,22 @@
(else
(lp #'rest (cons #'id e) r x))))))))
- (syntax-case stx (export import)
+ (syntax-case stx (export import srfi)
+ ;; (srfi :n ...) -> (srfi srfi-n)
+ ((_ (srfi colon-n name ...) rest ...)
+ (and (and-map identifier? #'(srfi name ...))
+ (symbol? (syntax->datum #'colon-n))
+ (eqv? (string-ref (symbol->string (syntax->datum #'colon-n)) 0)
+ #\:))
+ (let ((srfi-n (datum->syntax
+ #'colon-n
+ (string->symbol
+ (string-append
+ "srfi-"
+ (substring (symbol->string (syntax->datum #'colon-n))
+ 1))))))
+ #`(library (srfi #,srfi-n name ...)
+ rest ...)))
((_ (name name* ...)
(export espec ...)
(import ispec ...)
--
2.5.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] Transform R6RS SRFI module name on definition.
2015-10-02 21:45 [PATCH] Transform R6RS SRFI module name on definition Taylan Ulrich Bayırlı/Kammer
@ 2015-12-03 9:05 ` Taylan Ulrich Bayırlı/Kammer
2015-12-03 9:14 ` Taylan Ulrich Bayırlı/Kammer
0 siblings, 1 reply; 3+ messages in thread
From: Taylan Ulrich Bayırlı/Kammer @ 2015-12-03 9:05 UTC (permalink / raw)
To: guile-devel
taylanbayirli@gmail.com (Taylan Ulrich "Bayırlı/Kammer") writes:
> Currently our R6RS 'import' form automatically transforms an import like
> (srfi :n ...) to (srfi srfi-n ...).
>
> This works fine with the SRFIs that ship with Guile and any extra SRFI
> modules defined with the verbose name format (srfi srfi-n ...).
>
> However, when one really defines a library named (srfi :n ...), then
> 'import' fails to find this because it only looks for the verbose name.
>
> Here a transcript showcasing the issue:
>
> --- snip ---
> scheme@(guile-user)> (library (srfi :200) (export test) (import (rnrs base)) (define test 'test))
> scheme@(srfi :200)> ,m guile-user
> scheme@(guile-user)> (import (srfi :200))
> While compiling expression:
> ERROR: no code for module (srfi srfi-200)
> scheme@(guile-user)> ,use (srfi :200)
> scheme@(guile-user)> test
> $2 = test
> scheme@(guile-user)>
> --- snip ---
>
> (Use-modules actually finds it, as you see.)
>
> The attached patch makes our R6RS 'library' form automatically transform
> a library name like (srfi :n ...) to (srfi srfi-n ...).
>
> Will this leak out to the user in such a way that it breaks conformance
> or creates problems? Is it bad that this time 'use-modules' won't be
> able to find (srfi :n ...)? I don't think it is; users should just use
> (srfi :n ...) with 'import' and (srfi srfi-n ...) with 'use-modules'.
>
> Note that it's actually not 'import' itself that does the reverse
> transform but a deeper part of the system, and thus for instance the
> 'environment' form from (rnrs eval) also correctly resolves the module
> name (srfi :n ...) to (srfi srfi-n ...). If there are any "holes" left
> where the transform doesn't happen, we should be able to plug those too.
>
> WDYT?
Ping.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] Transform R6RS SRFI module name on definition.
2015-12-03 9:05 ` Taylan Ulrich Bayırlı/Kammer
@ 2015-12-03 9:14 ` Taylan Ulrich Bayırlı/Kammer
0 siblings, 0 replies; 3+ messages in thread
From: Taylan Ulrich Bayırlı/Kammer @ 2015-12-03 9:14 UTC (permalink / raw)
To: guile-devel
[-- Attachment #1: Type: text/plain, Size: 146 bytes --]
taylanbayirli@gmail.com (Taylan Ulrich "Bayırlı/Kammer") writes:
> Ping.
Oh and here's a version of the patch without copyright by me.
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Transform-R6RS-SRFI-module-names-on-definition.patch --]
[-- Type: text/x-diff, Size: 1988 bytes --]
From f4d509cf09c2771c4962745d0f04ab297a8647c9 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Taylan=20Ulrich=20Bay=C4=B1rl=C4=B1/Kammer?=
<taylanbayirli@gmail.com>
Date: Fri, 2 Oct 2015 23:29:08 +0200
Subject: [PATCH] Transform R6RS SRFI module names on definition.
* module/ice-9/r6rs-libraries.scm (library): Transform the names of
defined SRFI modules from (srfi :n ...) to (srfi srfi-n ...).
---
module/ice-9/r6rs-libraries.scm | 19 +++++++++++++++++--
1 file changed, 17 insertions(+), 2 deletions(-)
diff --git a/module/ice-9/r6rs-libraries.scm b/module/ice-9/r6rs-libraries.scm
index a68df3c..934332d 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, 2015 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
@@ -158,7 +158,22 @@
(else
(lp #'rest (cons #'id e) r x))))))))
- (syntax-case stx (export import)
+ (syntax-case stx (export import srfi)
+ ;; (srfi :n ...) -> (srfi srfi-n)
+ ((_ (srfi colon-n name ...) rest ...)
+ (and (and-map identifier? #'(srfi name ...))
+ (symbol? (syntax->datum #'colon-n))
+ (eqv? (string-ref (symbol->string (syntax->datum #'colon-n)) 0)
+ #\:))
+ (let ((srfi-n (datum->syntax
+ #'colon-n
+ (string->symbol
+ (string-append
+ "srfi-"
+ (substring (symbol->string (syntax->datum #'colon-n))
+ 1))))))
+ #`(library (srfi #,srfi-n name ...)
+ rest ...)))
((_ (name name* ...)
(export espec ...)
(import ispec ...)
--
2.6.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2015-12-03 9:14 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2015-10-02 21:45 [PATCH] Transform R6RS SRFI module name on definition Taylan Ulrich Bayırlı/Kammer
2015-12-03 9:05 ` Taylan Ulrich Bayırlı/Kammer
2015-12-03 9:14 ` Taylan Ulrich Bayırlı/Kammer
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).