From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Marco Maggi Newsgroups: gmane.lisp.guile.bugs Subject: bug#16158: psyntax: bug in bound-identifier=? Date: Mon, 16 Dec 2013 08:49:34 +0100 Message-ID: <87d2kxfd69.fsf@governatore.luna> References: <87bo0hfyq3.fsf@netris.org> Reply-To: marco.maggi-ipsu@poste.it NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain X-Trace: ger.gmane.org 1387180213 23128 80.91.229.3 (16 Dec 2013 07:50:13 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 16 Dec 2013 07:50:13 +0000 (UTC) Cc: 16158@debbugs.gnu.org To: Mark H Weaver Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Mon Dec 16 08:50:19 2013 Return-path: Envelope-to: guile-bugs@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 1VsSwV-0000t5-8u for guile-bugs@m.gmane.org; Mon, 16 Dec 2013 08:50:19 +0100 Original-Received: from localhost ([::1]:54246 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VsSwU-0004ch-QV for guile-bugs@m.gmane.org; Mon, 16 Dec 2013 02:50:18 -0500 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44392) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VsSwL-0004cN-R4 for bug-guile@gnu.org; Mon, 16 Dec 2013 02:50:15 -0500 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1VsSwG-0004kg-0x for bug-guile@gnu.org; Mon, 16 Dec 2013 02:50:09 -0500 Original-Received: from debbugs.gnu.org ([140.186.70.43]:38840) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1VsSwF-0004jX-My for bug-guile@gnu.org; Mon, 16 Dec 2013 02:50:03 -0500 Original-Received: from Debian-debbugs by debbugs.gnu.org with local (Exim 4.80) (envelope-from ) id 1VsSwE-00036O-BP for bug-guile@gnu.org; Mon, 16 Dec 2013 02:50:02 -0500 X-Loop: help-debbugs@gnu.org Resent-From: Marco Maggi Original-Sender: "Debbugs-submit" Resent-CC: bug-guile@gnu.org Resent-Date: Mon, 16 Dec 2013 07:50:02 +0000 Resent-Message-ID: Resent-Sender: help-debbugs@gnu.org X-GNU-PR-Message: followup 16158 X-GNU-PR-Package: guile X-GNU-PR-Keywords: Original-Received: via spool by 16158-submit@debbugs.gnu.org id=B16158.138718018311892 (code B ref 16158); Mon, 16 Dec 2013 07:50:02 +0000 Original-Received: (at 16158) by debbugs.gnu.org; 16 Dec 2013 07:49:43 +0000 Original-Received: from localhost ([127.0.0.1]:52859 helo=debbugs.gnu.org) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VsSvt-00035j-L4 for submit@debbugs.gnu.org; Mon, 16 Dec 2013 02:49:42 -0500 Original-Received: from relay-pt2.poste.it ([62.241.5.253]:42285) by debbugs.gnu.org with esmtp (Exim 4.80) (envelope-from ) id 1VsSvo-00035V-RV for 16158@debbugs.gnu.org; Mon, 16 Dec 2013 02:49:38 -0500 Original-Received: from governatore.luna (93.144.58.231) by relay-pt2.poste.it (8.5.142) (authenticated as marco.maggi-ipsu@poste.it) id 000000000088B902; Mon, 16 Dec 2013 08:49:32 +0100 Original-Sender: marco.maggi-ipsu@poste.it In-Reply-To: <87bo0hfyq3.fsf@netris.org> (Mark H. Weaver's message of "Sun, 15 Dec 2013 19:04:04 -0500") Original-Lines: 80 X-BeenThere: debbugs-submit@debbugs.gnu.org X-Mailman-Version: 2.1.15 Precedence: list X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 140.186.70.43 X-BeenThere: bug-guile@gnu.org List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:7363 Archived-At: Mark H Weaver wrote: > While reading psyntax.scm, I noticed that the definition of 'bound-id=?' > does not match the definition in "Syntax Abstraction in Scheme" by > Dybvig, Hieb, and Bruggeman. > > The paper states "Two identifiers that are bound-identifier=? are also > free-identifier=?". I think you are referring to this paragraph from the paper[1] (page 12): Two identifiers that are bound-identifier=? are also free-identifier=?, but two identifiers that are free-identifier=? may not be bound-identifier=?. An identifier introduced by a macro transformer may refer to the same enclosing binding as an identifier not introduced by the transformer, but an introduced binding for one will not capture references to the other. > The following expression shows that this is not the case in Guile 2.0: > > (let* ((x 1) (s1 #'x) > (x 2) (s2 #'x)) > (list (bound-identifier=? s1 s2) > (free-identifier=? s1 s2))) > => (#t #f) The expander in Ikarus/Vicare also returns this value. > Racket reports (#f #f) for the same expression. Racket is different because its expander implements a variant of phase separation; if the whole form is evaluated at phase N, the "x" in "#'x" should be searched among the bindings at phase N-1 (if any) (I am not authoritative in how Racket works, there is always something that escapes me). Your code works, but when you actually try to use the identifiers for something: #!r6rs (import (rnrs)) (define-syntax doit (lambda (stx) (let* ((x 1) (s1 #'x) (x 2) (s2 #'x)) #`(let ((#,s1 123)) #,s2)))) (doit) $ plt-r6rs ~/var/tmp/proof.sps /home/marco/var/tmp/proof.sps:7:23: x: identifier used out of context in: x context...: /opt/racket/5.3.5/lib/racket/collects/r6rs/run.rkt: [running body] while the same program works fine in Ikarus, Vicare, Sagittarius and Guile (Larceny's opinion would be interesting, but I do not have it installed). IMHO this program should work for Racket, too, but maybe it refuses to run code that "looks wrong" (indeed, usually, in a correct program we do not define identifiers this way). I dunno how Guile's evolution of psyntax works, but the two #'x must be bound-identifier=? because the following result must stand: (define-syntax doit (lambda (stx) (let* ((x 1) (s1 #'x) (x 2) (s2 #'x)) #`(let ((#,s1 123)) #,s2)))) (doit) => 123 IMHO it is an error in the paper. Some paragraphs from the paper preceding "the one" have been recycled in the R6RS document, but this one paragraph has not; maybe this means something. HTH [1] -- "Now feel the funk blast!" Rage Against the Machine - "Calm like a bomb"