From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: taylanbayirli@gmail.com (Taylan Ulrich =?utf-8?Q?Bay=C4=B1rl=C4=B1?= =?utf-8?Q?=2FKammer?=) Newsgroups: gmane.lisp.guile.devel Subject: [PATCH] Transform R6RS SRFI module name on definition. Date: Fri, 02 Oct 2015 23:45:13 +0200 Message-ID: <87vbapueqe.fsf@T420.taylan> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" X-Trace: ger.gmane.org 1443822573 16173 80.91.229.3 (2 Oct 2015 21:49:33 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Fri, 2 Oct 2015 21:49:33 +0000 (UTC) To: guile-devel@gnu.org Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Fri Oct 02 23:49:32 2015 Return-path: Envelope-to: guile-devel@m.gmane.org Original-Received: from lists.gnu.org ([208.118.235.17]) by plane.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1Zi8Cq-0002JR-0A for guile-devel@m.gmane.org; Fri, 02 Oct 2015 23:49:32 +0200 Original-Received: from localhost ([::1]:35333 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi8Co-0001E7-OZ for guile-devel@m.gmane.org; Fri, 02 Oct 2015 17:49:30 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:40100) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi88j-0000rp-M6 for guile-devel@gnu.org; Fri, 02 Oct 2015 17:45:18 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1Zi88i-0007q9-F2 for guile-devel@gnu.org; Fri, 02 Oct 2015 17:45:17 -0400 Original-Received: from mail-wi0-x234.google.com ([2a00:1450:400c:c05::234]:33637) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1Zi88i-0007pj-6o for guile-devel@gnu.org; Fri, 02 Oct 2015 17:45:16 -0400 Original-Received: by wiclk2 with SMTP id lk2so50885790wic.0 for ; Fri, 02 Oct 2015 14:45:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:subject:date:message-id:user-agent:mime-version :content-type; bh=SFSQDE3o7lnhPtUcA/5t0wtfBCgpkC0zLvhQ60DfTeo=; b=HLUr1dub1EUOq6uJup3C/77++EvPbB2zTGpQIY3Si6WOtdm1iw9KufZidApGdg5ukt 0T7eeSzaxs6AiDK7LNEmnZ8aTYKGZrJLQJCKwd1O8kW2zVn55udNR8igM0yZlF3TOG8i Wy6oE0KoyiVuIGzUvTrZlUtPqBgmcsnuciFlqiY9IZF3aUFzP4nioeCvmYVjxQeEs0BL 6k8mTbYKJPAJtZ1h+1f39JThinGzGXsoVtm/XK4zYHuXSsEe/mrKEiudyUkoY/1gRzBU KIhYgUOeL0egxWZKVLafvj80+FrqVmLrZHaKzIqp4IO3Zbu46Fa3Y37UlfpfrrTTfx12 7pwQ== X-Received: by 10.194.176.6 with SMTP id ce6mr18295027wjc.101.1443822315586; Fri, 02 Oct 2015 14:45:15 -0700 (PDT) Original-Received: from T420.taylan ([2a02:908:c32:4740:221:ccff:fe66:68f0]) by smtp.gmail.com with ESMTPSA id gt4sm907971wib.21.2015.10.02.14.45.14 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 02 Oct 2015 14:45:14 -0700 (PDT) User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: Error: Malformed IPv6 address (bad octet value). X-Received-From: 2a00:1450:400c:c05::234 X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:17888 Archived-At: --=-=-= Content-Type: text/plain 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? --=-=-= Content-Type: text/x-diff; charset=utf-8 Content-Disposition: inline; filename=0001-Transform-R6RS-SRFI-module-names-on-definition.patch Content-Transfer-Encoding: quoted-printable >From 952870469d852ca910558810de1c853124abd830 Mon Sep 17 00:00:00 2001 From: =3D?UTF-8?q?Taylan=3D20Ulrich=3D20Bay=3DC4=3DB1rl=3DC4=3DB1/Kammer?=3D 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' for= ms =20 -;; Copyright (C) 2010 Free Software Foundation, Inc. +;; Copyright (C) 2010 Free Software Foundation, Inc. +;; Copyright (C) 2015 Taylan Ulrich Bay=C4=B1rl=C4=B1/Kammer ;; ;; 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)))))))) =20 - (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 ...) --=20 2.5.0 --=-=-=--