From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: "Marijn Schouten (hkBst)" Newsgroups: gmane.lisp.guile.devel,gmane.comp.lang.racket.devel Subject: Re: [racket-dev] Enhancement to the syntax system? Date: Sat, 03 May 2014 23:29:21 +0200 Message-ID: <53655FB1.5060702@gentoo.org> References: <877gumufmq.fsf@gnu.org> <87r4stss4d.fsf@gnu.org> <878vf0o7gs.fsf@gnu.org> <87pq85dj8o.fsf@gnu.org> <87sjd058ia.fsf@gnu.org> <4FFC3D72.8070506@gentoo.org> <20476.16781.257276.194149@winooski.ccs.neu.edu> <20120710150315.B7B27650059@mail-svr1.cs.utah.edu> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Trace: ger.gmane.org 1399152593 8286 80.91.229.3 (3 May 2014 21:29:53 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Sat, 3 May 2014 21:29:53 +0000 (UTC) Cc: "dev@racket-lang.org" , =?UTF-8?B?THVkb3ZpYyBDb3VydMOocw==?= , guile-devel@gnu.org To: Matthew Flatt , Eli Barzilay Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat May 03 23:29:47 2014 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 1WghVB-00018f-6W for guile-devel@m.gmane.org; Sat, 03 May 2014 23:29:45 +0200 Original-Received: from localhost ([::1]:50325 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WghVA-0002jT-RV for guile-devel@m.gmane.org; Sat, 03 May 2014 17:29:44 -0400 Original-Received: from eggs.gnu.org ([2001:4830:134:3::10]:44889) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WghUz-0002jB-MB for guile-devel@gnu.org; Sat, 03 May 2014 17:29:42 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1WghUq-0001pN-9j for guile-devel@gnu.org; Sat, 03 May 2014 17:29:33 -0400 Original-Received: from woodpecker.gentoo.org ([2001:470:ea4a:1:214:c2ff:fe64:b2d3]:33375 helo=smtp.gentoo.org) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1WghUq-0001oP-3g; Sat, 03 May 2014 17:29:24 -0400 Original-Received: from [10.0.0.3] (193-81-151-99.adsl.highway.telekom.at [193.81.151.99]) (using TLSv1 with cipher ECDHE-RSA-AES128-SHA (128/128 bits)) (No client certificate requested) (Authenticated sender: hkbst) by smtp.gentoo.org (Postfix) with ESMTPSA id 75A283403C5; Sat, 3 May 2014 21:29:20 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:24.0) Gecko/20100101 Thunderbird/24.4.0 In-Reply-To: <20120710150315.B7B27650059@mail-svr1.cs.utah.edu> X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 2001:470:ea4a:1:214:c2ff:fe64:b2d3 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:17135 gmane.comp.lang.racket.devel:10745 Archived-At: On 07/10/2012 05:03 PM, Matthew Flatt wrote: > At Tue, 10 Jul 2012 10:51:57 -0400, Eli Barzilay wrote: >> 20 minutes ago, Marijn wrote: >>> >>> It seems to me that both these results cannot be correct >>> simultaneously, but I'll await the experts' opinion on that. >> >> This does look weird: >> >> #lang racket >> (define-for-syntax (f stx) #`(let ([x 1]) #,stx)) >> (define-syntax (m stx) >> (with-syntax ([zz (f #'x)]) #`(let ([x 2]) zz))) >> (m) >> >> evaluates to 1, but if I change the first two "stx" names into "x" >> *or* if I change the argument name for the macro to "x", then it >> returns 2. > > It's natural --- but not correct --- to think that #` is responsible > for hygiene, in which case `(f #'x)' should keep the given `x' separate > from the `let'-bound `x' in the result. > > Instead, hygiene is the responsibility of macro invocation, and > > #`(let ([x 1]) #,#'x) > > is simply the same as > > #`(let ([x 1]) x) > > and so > > (f #'x) > > above is equivalent to > > #`(let ([x 1]) x) IIUC then you're saying that also all the following (fx #'x) and (fy #'x) are equivalent to #`(let ((x 0)) x), but if you run this code then you will get a 0 result only for (myy), contrary to what I would expect based on the above explanation. #lang racket (define-for-syntax (fx x) #`(let ((x 0)) #,x)) (define-for-syntax (fy y) #`(let ((x 0)) #,y)) (define-syntax (mxx x) (syntax-case x () ((_) #`(let ((x 99)) #,(fx #'x))))) (define-syntax (mxy x) (syntax-case x () ((_) #`(let ((x 99)) #,(fy #'x))))) (define-syntax (myx y) (syntax-case y () ((_) #`(let ((x 99)) #,(fx #'x))))) (define-syntax (myy y) (syntax-case y () ((_) #`(let ((x 99)) #,(fy #'x))))) (mxx) (mxy) (myx) (myy) ==> 99 99 99 0 Marijn