From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: mhw@netris.org Newsgroups: gmane.lisp.guile.user Subject: Re: exporting procedure else now breaks case's else clause Date: Sun, 14 Sep 2014 22:14:42 -0400 Message-ID: <87d2axy6i5.fsf@netris.org> References: <87y4tmilna.fsf@drakenvlieg.flower> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1410747326 1828 80.91.229.3 (15 Sep 2014 02:15:26 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 15 Sep 2014 02:15:26 +0000 (UTC) Cc: guile-user@gnu.org To: Jan Nieuwenhuizen Original-X-From: guile-user-bounces+guile-user=m.gmane.org@gnu.org Mon Sep 15 04:15:19 2014 Return-path: Envelope-to: guile-user@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 1XTLp1-0007cL-63 for guile-user@m.gmane.org; Mon, 15 Sep 2014 04:15:19 +0200 Original-Received: from localhost ([::1]:56868 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XTLp0-0000R3-Ou for guile-user@m.gmane.org; Sun, 14 Sep 2014 22:15:18 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:58950) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XTLon-0000Ld-EG for guile-user@gnu.org; Sun, 14 Sep 2014 22:15:11 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XTLoZ-0005Rv-GK for guile-user@gnu.org; Sun, 14 Sep 2014 22:15:05 -0400 Original-Received: from world.peace.net ([96.39.62.75]:43188) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XTLoZ-0005Rc-Cy; Sun, 14 Sep 2014 22:14:51 -0400 Original-Received: from c-24-62-95-23.hsd1.ma.comcast.net ([24.62.95.23] helo=jojen) by world.peace.net with esmtpsa (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.72) (envelope-from ) id 1XTLoS-0007JH-2T; Sun, 14 Sep 2014 22:14:44 -0400 In-Reply-To: <87y4tmilna.fsf@drakenvlieg.flower> (Jan Nieuwenhuizen's message of "Sun, 14 Sep 2014 11:42:01 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.3 (gnu/linux) X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.6.x X-Received-From: 96.39.62.75 X-BeenThere: guile-user@gnu.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: General Guile related discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: guile-user-bounces+guile-user=m.gmane.org@gnu.org Original-Sender: guile-user-bounces+guile-user=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.user:11504 Archived-At: Jan Nieuwenhuizen writes: > Hi, > > In stable-2.0, this works > > (define-module (case) #:export (else)) > (define (else ast) (if (> (length ast) 3) (cadddr ast) #f)) > (define t 't) (case t ((t) #t) (else (eq? t 't))) > > with latest master it breaks as soon as else is added to the exports > list: > > ;;; > /home/janneke/vc/verum/development/gaiag/module/gaiag/case.scm:9:31: > case: invalid clause in subform (else (eq? t (quote t))) of (case t > ((t) #t) (else (eq? t (quote t)))) > language/cps/reify-primitives.scm:75:11: In procedure # 2477220 at ice-9/boot-9.scm:509:12 (expr clause clauses)>: > language/cps/reify-primitives.scm:75:11: Syntax error: > /home/janneke/vc/verum/development/gaiag/module/gaiag/case.scm:9:31: > case: invalid clause in subform (else (eq? t (quote t))) of (case t > ((t) #t) (else (eq? t (quote t)))) > > Bug or feature? Master's behavior here is correct. According to both R6RS and R7RS, syntax literals such as 'else' and '=>' match by comparing bindings instead of names. In other words, the binding for 'else' in effect where the 'case' macro was defined must be the same as the binding for 'else' where you used the case macro, in order for it to match. R6RS also allows another way for the syntax literals to match: if 'else' is unbound in both the definition and usage sites, then it suffices for them to have the same name. The intent in modern scheme is that these literals are treated like any other bindings: 'else' and '=>' are exported from R6RS's (rnrs base) and R7RS's (scheme base) libraries. For example, you should be able to rename these identifiers when you import them, and then use your alternate names for them instead of the standard names. For historical reasons, 'else' and '=>' are neither bound nor exported from Guile's standard libraries, so we rely on the name-based matching specified by R6RS. The behavior of Guile 2.0.x is non-standard. It matches syntax literals if their names match and either (A) both have the same *non-toplevel* binding, or (B) neither have a *non-toplevel* binding. In other words, in Guile 2.0.x, toplevel bindings are completely ignored for purposes of matching syntax literals, and the names must match in all cases, so it's not possible to rename syntax literals within a module. Regards, Mark