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: Enhancement to the syntax system? Date: Sat, 30 Jun 2012 17:22:52 +0200 Message-ID: NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: multipart/alternative; boundary=f46d044788176d9b2704c3b223d1 X-Trace: dough.gmane.org 1341069784 20298 80.91.229.3 (30 Jun 2012 15:23:04 GMT) X-Complaints-To: usenet@dough.gmane.org NNTP-Posting-Date: Sat, 30 Jun 2012 15:23:04 +0000 (UTC) To: guile-devel Original-X-From: guile-devel-bounces+guile-devel=m.gmane.org@gnu.org Sat Jun 30 17:23:03 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 1SkzVn-0006sV-12 for guile-devel@m.gmane.org; Sat, 30 Jun 2012 17:23:03 +0200 Original-Received: from localhost ([::1]:57443 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SkzVm-0004Nm-QU for guile-devel@m.gmane.org; Sat, 30 Jun 2012 11:23:02 -0400 Original-Received: from eggs.gnu.org ([208.118.235.92]:46285) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SkzVi-0004NQ-D6 for guile-devel@gnu.org; Sat, 30 Jun 2012 11:23:00 -0400 Original-Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1SkzVg-0003PT-7V for guile-devel@gnu.org; Sat, 30 Jun 2012 11:22:57 -0400 Original-Received: from mail-ob0-f169.google.com ([209.85.214.169]:33816) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1SkzVf-0003OV-Ut for guile-devel@gnu.org; Sat, 30 Jun 2012 11:22:56 -0400 Original-Received: by obhx4 with SMTP id x4so1184553obh.0 for ; Sat, 30 Jun 2012 08:22:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:date:message-id:subject:from:to:content-type; bh=7+9EQdsNqoS+tGihcBunxZxoe3fuREIAOrcCKBGb6E8=; b=qlbobmep+Je3iYQVzp3AOo8NHNnqR6McARcJMFf6i2JDsahAZdPzxv4MOPL0IRqhBF /TjL3eejJtUAsXnzQaatfKgtOd6vXhvhsetSIE7f7zxcT0mY6TuGrMuQDE3Hbn5HR0Z3 r2+13T6G/z0z2GDLPtQ44f2+BvLymkm8GQCg/1k3QU/5xvY+t5KhQd5Y5HnJg3WVm6Yj H3SfZ1ONtubpt4ptjAu9auh6cLbL1jYyjt1Mki6X2356sOiKXEIpHDD6ty4KkFCqSfFh RHUWz5o/BV7deZjwcxwEqVi8Q6EY9hKRpE4ABqX7RWQucHlOI9tAd8kgRF79yC9SN0UC el/A== Original-Received: by 10.50.190.163 with SMTP id gr3mr1715717igc.22.1341069772823; Sat, 30 Jun 2012 08:22:52 -0700 (PDT) Original-Received: by 10.50.41.196 with HTTP; Sat, 30 Jun 2012 08:22:52 -0700 (PDT) X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 209.85.214.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:14680 Archived-At: --f46d044788176d9b2704c3b223d1 Content-Type: text/plain; charset=ISO-8859-1 Hi, I want to discuss some of my experiences using the current syntax system when making the racket match matcher utilizing syntax-parse. When doing this I tried to use another style of macro parsing then seen in guiles ice-9 match e.g. Alex Shinns matcher for example. What I mean here is that I tried to use #' #, #,@ and calling out to functions in stead of writing one more macro. This works but it has a caveat. Hygiene is harder to maintain. e.g. I kept on hitting this kind of code snippets #'(let ((x v)) #,(f rest #'x)) The problem with this code is hygiene, I need to make a gensym and use with-syntax to bound x to that gensym in order to be safe at the macro expansion. Apart from this I liked the flow of the program and how natural it was to comprehend the code. The downside to this style is that we looses safety with respect to hygiene bugs. So can we improve on this. I would say yes! Consider introduceing #. and #.@ that works very much like #, and #,@ but with the distinction that #. creates a syntactic lambda e.g. The construction of the syntax object translates to #'(let ((x v)) #.(f rest #'x)) => #'(let ((x v)) #,(lambda (env) (with-syntax-env env (f rest #'x))) E.g. we inject a lambda inside the syntax structure to be parsed by the syntax expander later on and the syntax expander will recognize the lambda and call it with the current environment of the expander. The lambda will in turn set the syntax env that should be used by the #'x form in order match that x with the bounded x. I think that you get my intention. The question is why something like this does not exists. Is it because of weaknesses making this procedure unsound or any other reasons. I do think such a feature would be important but on the other hand, someone should have thought about this before and rejected the idea so my question is simply why is this rejected any clues or pointers? /Regards Stefan --f46d044788176d9b2704c3b223d1 Content-Type: text/html; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Hi,

I want to discuss some of my experiences using the current synta= x system when making the racket match
matcher utilizing syntax-parse.
When doing this I tried to use another style of macro parsing then see= n in guiles ice-9 match e.g. Alex Shinns matcher for example. What I mean h= ere is that I tried to use #' #, #,@ and calling out to functions in st= ead of writing one more macro. This works but it has a caveat.
Hygiene is harder to maintain. e.g.=A0 I kept on hitting this kind of code = snippets

#'(let ((x v))
=A0=A0=A0 #,(f rest #'x))
The problem with this code is hygiene, I need to make a gensym and use wit= h-syntax to bound x to that gensym in order to be safe
at the macro expansion. Apart from this I liked the flow of the program and= how natural it was to comprehend the code.

The downside to this sty= le is that we looses safety with respect to hygiene bugs. So can we improve= on this. I would say yes!
Consider introduceing #. and #.@ that works very much like #, and #,@ but w= ith the distinction that #. creates a syntactic lambda e.g.
The construc= tion of the syntax object translates to
#'(let ((x v)) #.(f rest #&#= 39;x))

=3D>

#'(let ((x v)) #,(lambda (env) (with-syntax-env env = (f rest #'x)))

E.g. we inject a lambda inside the syntax structu= re to be parsed by the syntax expander later on and the syntax expander
will recognize the lambda and call it with the current environment of the e= xpander. The lambda will in turn set the syntax env that
should be used= by the #'x form in order match that x with the bounded x. I think that= you get my intention.

The question is why something like this does not exists. Is it because = of weaknesses making this procedure unsound or any other reasons. I do thin= k such a feature would be important but on the other hand, someone should h= ave thought about this before and rejected the idea so my question is simpl= y why is this rejected any clues or pointers?

/Regards
Stefan


--f46d044788176d9b2704c3b223d1--