unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
* Enhancement to the syntax system?
@ 2012-06-30 15:22 Stefan Israelsson Tampe
  2012-07-02 19:28 ` Ludovic Courtès
  0 siblings, 1 reply; 24+ messages in thread
From: Stefan Israelsson Tampe @ 2012-06-30 15:22 UTC (permalink / raw)
  To: guile-devel

[-- Attachment #1: Type: text/plain, Size: 1925 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 2091 bytes --]

^ permalink raw reply	[flat|nested] 24+ messages in thread

end of thread, other threads:[~2014-05-03 21:29 UTC | newest]

Thread overview: 24+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-06-30 15:22 Enhancement to the syntax system? Stefan Israelsson Tampe
2012-07-02 19:28 ` Ludovic Courtès
2012-07-02 20:43   ` Stefan Israelsson Tampe
2012-07-02 22:41     ` Ludovic Courtès
2012-07-03 14:37       ` Stefan Israelsson Tampe
2012-07-03 21:33         ` Ludovic Courtès
2012-07-03 21:52           ` Stefan Israelsson Tampe
2012-07-04  7:47             ` Marijn
2012-07-04  8:04               ` Stefan Israelsson Tampe
2012-07-09 15:52             ` Ludovic Courtès
2012-07-09 17:40               ` Stefan Israelsson Tampe
2012-07-10  8:24                 ` Ludovic Courtès
2012-07-10 13:35                   ` Stefan Israelsson Tampe
2012-07-10 14:34                     ` Marijn
2012-07-10 14:51                       ` [racket-dev] " Eli Barzilay
     [not found]                         ` <20476.16781.257276.194149-a5nvgYPMCZcx/1z6v04GWfZ8FUJU4vz8@public.gmane.org>
2012-07-10 15:03                           ` Matthew Flatt
2012-07-10 15:26                             ` [racket-dev] " Ludovic Courtès
2012-07-10 15:44                               ` Stefan Israelsson Tampe
2012-07-10 17:47                                 ` Stefan Israelsson Tampe
2012-07-10 16:48                             ` Eli Barzilay
2014-05-03 21:29                             ` Marijn Schouten (hkBst)
2012-07-10 15:44                           ` Ryan Culpepper
2012-07-10 15:22                     ` Ludovic Courtès
2012-07-10  7:36               ` Stefan Israelsson Tampe

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).