From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Andy Wingo Newsgroups: gmane.lisp.guile.devel Subject: Re: define-syntax Date: Wed, 16 Jun 2010 00:06:10 +0200 Message-ID: References: <87bpbcm381.fsf@gnu.org> NNTP-Posting-Host: lo.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Trace: dough.gmane.org 1276640188 10647 80.91.229.12 (15 Jun 2010 22:16:28 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Tue, 15 Jun 2010 22:16:28 +0000 (UTC) Cc: guile-devel@gnu.org To: ludo@gnu.org (Ludovic =?utf-8?Q?Court=C3=A8s?=) Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Wed Jun 16 00:16:26 2010 connect(): No such file or directory Return-path: Envelope-to: guile-devel@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 1OOeQk-0007Fm-Eo for guile-devel@m.gmane.org; Wed, 16 Jun 2010 00:16:26 +0200 Original-Received: from localhost ([127.0.0.1]:52069 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OOeHN-0003Ac-EN for guile-devel@m.gmane.org; Tue, 15 Jun 2010 18:06:45 -0400 Original-Received: from [140.186.70.92] (port=46981 helo=eggs.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1OOeH8-0002aP-M9 for guile-devel@gnu.org; Tue, 15 Jun 2010 18:06:41 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.69) (envelope-from ) id 1OOeEX-0001dW-QY for guile-devel@gnu.org; Tue, 15 Jun 2010 18:03:51 -0400 Original-Received: from a-pb-sasl-quonix.pobox.com ([208.72.237.25]:63840 helo=sasl.smtp.pobox.com) by eggs.gnu.org with esmtp (Exim 4.69) (envelope-from ) id 1OOeEX-0001dP-Ov; Tue, 15 Jun 2010 18:03:49 -0400 Original-Received: from sasl.smtp.pobox.com (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 3CFB1BCD5B; Tue, 15 Jun 2010 18:03:49 -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:content-transfer-encoding; s=sasl; bh=X5IaFeplKybv jsYZB1B/KlffS3c=; b=XG2+L7NgXRWWpoZVLV2uB8uVd65xMSL6NRwUR3VcTZK/ qEZGic/exY1nWd08xqKIVycAfxk0YGDINWmDfgOopPwD0nK0snYbAWMYOP+0HMFE KMZzhaxoW+n2wD4KRWhOQaT+0AzGoUYNjLRk7g0p7PH+2WXBabwB4aRe6UUkgm0= 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:content-transfer-encoding; q=dns; s=sasl; b=hIsA8C OumUrfDrlMUkHUKvOh2V5SKVoWXUlkncz5YLzgKvSX+90w6/JY84dOemGZyS41B9 Z6smJD01SR6qRuGK0oxgkI1NpG2PJQU482nqd8L19yR6FvBXFvAn1Nkp2hiqxyS0 Vei7THJp6evH4KJy3+d9XLYATWek80NlN8iPg= Original-Received: from a-pb-sasl-quonix. (unknown [127.0.0.1]) by a-pb-sasl-quonix.pobox.com (Postfix) with ESMTP id 27599BCD56; Tue, 15 Jun 2010 18:03:48 -0400 (EDT) Original-Received: from unquote (unknown [81.39.158.44]) (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 87ABEBCD53; Tue, 15 Jun 2010 18:03:46 -0400 (EDT) In-Reply-To: <87bpbcm381.fsf@gnu.org> ("Ludovic =?utf-8?Q?Court=C3=A8s=22'?= =?utf-8?Q?s?= message of "Tue, 15 Jun 2010 22:48:46 +0200") User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/23.0.92 (gnu/linux) X-Pobox-Relay-ID: DFB490D0-78C9-11DF-B27C-9056EE7EF46B-02397024!a-pb-sasl-quonix.pobox.com X-detected-operating-system: by eggs.gnu.org: Solaris 10 (beta) X-BeenThere: guile-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Developers list for Guile, the GNU extensibility library" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Original-Sender: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Errors-To: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Xref: news.gmane.org gmane.lisp.guile.devel:10492 Archived-At: Hi, On Tue 15 Jun 2010 22:48, ludo@gnu.org (Ludovic Court=C3=A8s) writes: > From R6RS Section 10: > > define-syntax form The expander expands and evaluates the > right-hand-side expression and binds the keyword to the resulting > transformer. > > Thus I think the following should work: > An interesting issue, and an interesting example. The problem boils down to eval-when. $ cat > foo.scm (define-syntax + (let ((plus +)) ;; `+' should resolve to whatever `+' is bound to ;; before this definition (lambda (stx) (syntax-case stx () ((_ args ...) (apply plus (map syntax->datum #'(args ...)))))))) ^D $ guile -l foo.scm -c '(begin (display (+ 1 2 3)) (newline))' 6 Indeed + does resolve to whatever + was bound to before the definition; it's just that when you define the + macro it usually defines at compile-time too! By compiling ahead of time and exiting we leave + in its pristine state. See also the discussion of eval-syntax-expanders-when in psyntax.scm or in http://www.scheme.com/csug8/system.html#./system:s78. Cheers, Andy --=20 http://wingolog.org/