From mboxrd@z Thu Jan 1 00:00:00 1970 Path: news.gmane.org!not-for-mail From: Stefan Israelsson Tampe Newsgroups: gmane.lisp.guile.devel Subject: Re: Enhancement to the syntax system? Date: Mon, 9 Jul 2012 19:40:33 +0200 Message-ID: References: <877gumufmq.fsf@gnu.org> <87r4stss4d.fsf@gnu.org> <878vf0o7gs.fsf@gnu.org> <87pq85dj8o.fsf@gnu.org> NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=e89a8f234cbf625b2a04c4691c50 X-Trace: dough.gmane.org 1341855652 12059 80.91.229.3 (9 Jul 2012 17:40:52 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Mon, 9 Jul 2012 17:40:52 +0000 (UTC) Cc: guile-devel@gnu.org To: =?ISO-8859-1?Q?Ludovic_Court=E8s?= Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Mon Jul 09 19:40:51 2012 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 1SoHx2-0003N4-Nx for guile-devel@m.gmane.org; Mon, 09 Jul 2012 19:40:48 +0200 Original-Received: from localhost ([::1]:52946 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoHx1-0001w1-I2 for guile-devel@m.gmane.org; Mon, 09 Jul 2012 13:40:47 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:56441) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoHwy-0001vo-6O for guile-devel@gnu.org; Mon, 09 Jul 2012 13:40:45 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SoHwr-00037O-MJ for guile-devel@gnu.org; Mon, 09 Jul 2012 13:40:43 -0400 Original-Received: from mail-gg0-f169.google.com ([209.85.161.169]:58505) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SoHwr-00035H-E0; Mon, 09 Jul 2012 13:40:37 -0400 Original-Received: by ggm4 with SMTP id 4so11982093ggm.0 for ; Mon, 09 Jul 2012 10:40:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=6K2quoVL1v6Tjt9rhHCtuInCKIeVsMgpy/S19EREKYQ=; b=yFxuDFA/jwtLp471w2DTj+RKzQzKuXyl8yHGyCXk+0Qsmhve8G7Tpf0NagZHgl4+tB hAGaQOzdGAyHQHrXspF+m+NV5bfzHyVWpMQABhQ/H9NXlNE9w0i0y67oL4cmuYy91+Kh tv4dINW2L+KMY+IuB/lcZFvyDasVvawmwczfsspUJjcA9tCZGe4XDV6NcX1KyP5ByM9m eAy+3q9038k+sgmZj63nbcTcG7ia0SdI/SuYCAezo8c3jZjhUBTUQzEfHIYpJNCRp/Y2 TmEdqHZLc5mSm2WC9KUqf/vA/x04WYPWh/En8u4XlU7Uto1Kn4l1s+dmQ61zaV/6f12x o0Xw== Original-Received: by 10.50.104.228 with SMTP id gh4mr8898678igb.71.1341855633660; Mon, 09 Jul 2012 10:40:33 -0700 (PDT) Original-Received: by 10.50.41.196 with HTTP; Mon, 9 Jul 2012 10:40:33 -0700 (PDT) In-Reply-To: <87pq85dj8o.fsf@gnu.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.161.169 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:14722 Archived-At: --e89a8f234cbf625b2a04c4691c50 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: quoted-printable | It=92s true that it=92s annoying that the wrong binding is silently used. | Do you think it=92s common enough to justify new syntax? Yes this highlights a comon problem when implementing racket match with #`. I do think that the best solution is to somehow extend the syntax expander to mimic my sugested #. and #.@. The simple solution is to rewrite according to #`(... #.((x y) (f #'x #'y))) -> #`(let-syntax ((g (lambda (x) (syntax-case x () ((_ x y) (f #'x #'y)))))) (... (g x y)) But before going this path it would be interesting to hear what the true wizards of scheme have to say about this. It might have been considered already and good advice could be taken from them. I also feel that the issue needs to be liffted up to the community of at least syntax-case user crowd before doing anything Ill try to spur some discussions on it and come back later! /Stefan On Mon, Jul 9, 2012 at 5:52 PM, Ludovic Court=E8s wrote: > Hi! > > Stefan Israelsson Tampe skribis: > > > You do not need gensyms if you try to mimic or implement my suggested #= . > . > > On the > > other hand when if you do this > > > > (define (f stx) #`(let ((x 1)) #,stx)) > > > > and use this with > > > > #`(let ((x 2)) #,(f #'x)) > > OK, got it, thanks! > > (In case others wonder, the complete example is: > > (define (f stx) > #`(let ((x 1)) #,stx)) > (define-syntax foo > (lambda (s) > (syntax-case s () > ((_) > #`(let ((x 2)) #,(f #'x)))))) > > (foo) > =3D> 1 > ) > > The situation can be diagnosed with: > > (define (f stx) > #`(let ((x 1)) > #,(if (bound-identifier=3D? stx #'x) (error) stx))) > > But it doesn=92t help. > > > (with-syntax ((x (datum->syntax stx (gensym "x")))) #`(let ((x 2)) #,(f > > #'x)))))) > > Often, you could use =91generate-temporaries=92, which is a bit nicer. > > > Hope that this makes things clear! > > It does, thanks! > > It=92s true that it=92s annoying that the wrong binding is silently used. > Do you think it=92s common enough to justify new syntax? > > Thanks, > Ludo=92. > > > --e89a8f234cbf625b2a04c4691c50 Content-Type: text/html; charset=windows-1252 Content-Transfer-Encoding: quoted-printable

| It=92s true that it=92s annoying that the wrong binding is silently used.=
| Do you think it=92s common enough to justify new syntax?

Yes this highlights a comon problem when implementing racket match with= #`. I do think
that the best solution is to somehow extend the syntax e= xpander to mimic my sugested
#. and #.@. The simple solution is to rewri= te according to

#`(... #.((x y) (f #'x #'y)))

->

#`(let-syntax= ((g (lambda (x) (syntax-case x () ((_ x y) (f #'x #'y))))))
=A0= =A0=A0=A0=A0 (... (g x y))

But before going this path it would be in= teresting to hear what the true wizards of
scheme have to say about this. It might have been considered already and go= od
advice could be taken from them. I also feel that the issue needs to = be liffted up to the
community of at least syntax-case user crowd befor= e doing anything Ill try to spur
some discussions on it and come back later!

/Stefan

On Mon, Jul 9, 2012 at 5:52 PM, Ludovic Court=E8s <ludo@gnu.o= rg> wrote:
Hi!

Stefan Israelsson Tampe <stef= an.itampe@gmail.com> skribis:

> You do not need gensyms if you try to mimic or= implement my suggested #. .
> On the
> other hand when if you do this
>
> (define (f stx) #`(let ((x 1)) #,stx))
>
> and use this with
>
> #`(let ((x 2)) #,(f #'x))

OK, got it, thanks!

(In case others wonder, the complete example is:

=A0 (define (f stx)
=A0 =A0 #`(let ((x 1)) #,stx))
=A0 (define-syntax foo
=A0 =A0 (lambda (s)
=A0 =A0 =A0 (syntax-case s ()
=A0 =A0 =A0 =A0 ((_)
=A0 =A0 =A0 =A0 =A0#`(let ((x 2)) #,(f #'x))))))

=A0 (foo)
=A0 =3D> 1
)

The situation can be diagnosed with:

=A0 (define (f stx)
=A0 =A0 #`(let ((x 1))
=A0 =A0 =A0 #,(if (bound-identifier=3D? stx #'x) (error) stx)))
But it doesn=92t help.

> (with-syntax ((x (datum->syntax stx (gensym "x")))) #`(le= t ((x 2)) #,(f
> #'x))))))

Often, you could use =91generate-temporaries=92, which is a bit nicer= .

> Hope that this makes things clear!

It does, thanks!

It=92s true that it=92s annoying that the wrong binding is silently used. Do you think it=92s common enough to justify new syntax?

Thanks,
Ludo=92.



--e89a8f234cbf625b2a04c4691c50--