From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.bugs Subject: Re: [r6rs] probably bad syntax expansion Date: Sun, 08 Aug 2010 12:41:06 +0200 Message-ID: References: <87d3vk4xz7.fsf@rapitore.luna> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: dough.gmane.org 1281289837 32504 80.91.229.12 (8 Aug 2010 17:50:37 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sun, 8 Aug 2010 17:50:37 +0000 (UTC) Cc: bug-guile@gnu.org To: Marco Maggi Original-X-From: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Sun Aug 08 19:50:36 2010 Return-path: Envelope-to: guile-bugs@m.gmane.org Original-Received: from lists.gnu.org ([199.232.76.165]) by lo.gmane.org with esmtp (Exim 4.69) (envelope-from ) id 1OiA13-0005RB-Bt for guile-bugs@m.gmane.org; Sun, 08 Aug 2010 19:50:33 +0200 Original-Received: from localhost ([127.0.0.1]:48101 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OiA12-0005xT-MT for guile-bugs@m.gmane.org; Sun, 08 Aug 2010 13:50:32 -0400 Original-Received: from [140.186.70.92] (port=49764 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1Oi91t-0002l7-FT for bug-guile@gnu.org; Sun, 08 Aug 2010 12:47:27 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1Oi3Ia-0001Ue-IT for bug-guile@gnu.org; Sun, 08 Aug 2010 06:40:13 -0400 Original-Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:55538 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1Oi3Ia-0005pU-Cw for bug-guile@gnu.org; Sun, 08 Aug 2010 06:40:12 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id E14D4CAA5F; Sun, 8 Aug 2010 06:38:13 -0400 (EDT) DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; s=sasl; bh=cSSSzI0e8A5+qk0ZPSBzAX+Krtc=; b=rmiXKg da5bQ6lW5oSYBjwdkav3MSQ7lr6dVsECcKU+uwmleaCGJffN9FtmH7/zAW+gCAkh 7y5KbJzZChC3f8Y92rf5GML6gg6Z7zZS/kOg9b3WuXR/wzEQxNgRb0FqnxBUhyMd 7/MJmIUh7MG3QfmjoCSGe/3bE+JlCVntxL5Bs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=pobox.com; h=from:to:cc :subject:references:date:in-reply-to:message-id:mime-version :content-type; q=dns; s=sasl; b=sFJrPXowa4auCU4jHk3bC3HR9APJ1zi6 aF7fA70Zhox+/dQn7YaHsu8TdyN0zjBcDpfethBIAb2SrA/iPqQCaJvF+UidOzsR UnSOfku7Na8+QsI1BzrDAam/YcOJsTYC5MaGsWw8+By6zjcJ459cktyQ5cZOCMsB dxY6dFJuyHA= Original-Received: from a-pb-sasl-quonix. (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id CEB30CAA5E; Sun, 8 Aug 2010 06:38:12 -0400 (EDT) Original-Received: from unquote.localdomain (unknown [79.156.64.132]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTPSA id EF31ACAA5D; Sun, 8 Aug 2010 06:38:10 -0400 (EDT) In-Reply-To: (Andy Wingo's message of "Mon, 21 Jun 2010 21:24:10 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.2 (gnu/linux) X-Pobox-Relay-ID: 0B74940C-A2D9-11DF-812E-9056EE7EF46B-02397024!a-pb-sasl-quonix.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-BeenThere: bug-guile@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Bug reports for GUILE, GNU's Ubiquitous Extension Language" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Errors-To: bug-guile-bounces+guile-bugs=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.bugs:4732 Archived-At: Hello, On Mon 21 Jun 2010 21:24, Andy Wingo writes: > On Mon 21 Jun 2010 09:59, Marco Maggi writes: > >> (define A ) >> (define-syntax B <>) >> (A) > > I have abbreviated your illuminating example. I don't really know what > to think of it, except to say that for top-level programs Guile > implements "REPL semantics". This is not quite the right explanation of the situation. Here is what I have put in the section "R6RS incompatibilities" in the manual. Instead of using the algorithm detailed in chapter 10 of the R6RS, expansion of toplevel forms happens sequentially. For example, while the expansion of the following set of recursive nested definitions does do the correct thing: @example (let () (define even? (lambda (x) (or (= x 0) (odd? (- x 1))))) (define-syntax odd? (syntax-rules () ((odd? x) (not (even? x))))) (even? 10)) @result{} #t @end example @noindent The same definitions at the toplevel do not: @example (begin (define even? (lambda (x) (or (= x 0) (odd? (- x 1))))) (define-syntax odd? (syntax-rules () ((odd? x) (not (even? x))))) (even? 10)) :4:18: In procedure even?: :4:18: Wrong type to apply: # @end example This is because when expanding the right-hand-side of @code{even?}, the reference to @code{odd?} is not yet marked as a syntax transformer, so it is assumed to be a function. While it is likely that we can fix the case of toplevel forms nested in a @code{begin} or a @code{library} form, a fix for toplevel programs seems trickier to implement in a backward-compatible way. Suggestions and/or patches would be appreciated. Admittedly, it seems silly to document incompatibilities instead of fixing them :P Andy -- http://wingolog.org/