unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Michael Lucy <MichaelGLucy@Gmail.com>
To: Noah Lavine <noah.b.lavine@gmail.com>
Cc: "Andy Wingo" <wingo@pobox.com>, "Ludovic Courtès" <ludo@gnu.org>,
	guile-devel@gnu.org
Subject: Re: PEG Parser
Date: Fri, 28 Jan 2011 22:15:15 -0600	[thread overview]
Message-ID: <AANLkTimUm_UL9W7EvfoF273U7E7sgOQB8feL-s2=5QfH@mail.gmail.com> (raw)
In-Reply-To: <AANLkTim_cHYYRXH=8DV3m_n9-XZKyhvu=4qXMmQOduHT@mail.gmail.com>

On Fri, Jan 28, 2011 at 9:07 PM, Noah Lavine <noah.b.lavine@gmail.com> wrote:
> Hello,
>
>> Indeed!  I'm looking forward to having it in Guile.
>
> Great! I don't intend to be pressuring you to merge it, by the way. I
> hope my message didn't come across that way.
>
>> The reason I didn't merge it yet was twofold: (1) the commit logs were
>> not in the standard style, and (2) I wasn't comfortable with the macro
>> binding stuff.  (2) was sufficiently big that I didn't have time to fix
>> it up.  My apologies for stalling on this...  But maybe now is the time
>> to look at it again!
>
> Yes, the binding stuff actually seemed very weird to me too, mostly
> because it's very non-idiomatic. More specifically, the peg module
> does most of its code generation in regular functions rather than
> macros. safe-bind implements hygiene for these code-generating
> functions. It's basically what you'd get with defmacro.
>
> I eventually came to the conclusion, however, that it's really a
> symptom of a larger issue.  Most likely it would be possible to take
> all of the functions that use safe-bind and rewrite them as macros
> themselves, using either syntax-case or syntax-rules. However, I am
> afraid that the result might be incredibly ugly. In order to make the
> code more readable, we use normal functions for code generation and
> provide hygiene through safe-bind.
>
> So the larger issue is that Scheme needs nicer-looking ways to define
> macros. If it had those, we wouldn't be using hacks like safe-bind.
> But we don't, and that's a huge issue to tackle.
>
> Those are my thoughts, but I would be quite curious to know if you (or
> anyone else) think the same way, or think something different is going
> on.

So, that's sort of a complicated story.  The safe-bind thing is a
standard idiom in the Common Lisp world (although it goes by many
names).  The most immediate reason it's there is that I was struggling
a bit with the hygienic macro system and fell back on what I knew,
then ran out of time trying to turn everything into a syntax-case
macro before the end of GSOC (which is why the data gets turned into
syntax at several points near the end of the process).

If we're talking about root causes, I think you're about right, at
least in my case.  It's pretty standard in the CL world to write large
macros by breaking the code out into functions, because it's
considered easier to reason about functions than macros.  I remember
Andy told me that functions can generate syntax, and I tried that, but
I had a remarkably hard time making it actually work correctly.  Part
of the problem was probably that I never really understood how syntax
worked, whereas I understand very well how lists work.

Also, macros are notoriously difficult to debug, especially when
they're generating several hundred lines of code that compiles fine
but mysteriously produces the wrong result after a seemingly trivial
change.  So porting them from list generation to syntax generation
turned out to be harder in practice than I had thought it would be.

>
> Noah
>



  reply	other threads:[~2011-01-29  4:15 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-01-13 21:29 PEG Parser Noah Lavine
2011-01-17 21:32 ` Ludovic Courtès
2011-01-21 15:23   ` Noah Lavine
2011-01-22 21:02     ` Ludovic Courtès
2011-01-24  1:29       ` Noah Lavine
2011-01-24 20:55         ` Ludovic Courtès
2011-01-27  1:40         ` Noah Lavine
2011-01-27  2:23           ` Michael Lucy
2011-01-27  2:38             ` Noah Lavine
2011-01-27  3:02               ` Michael Lucy
2011-01-27  5:17                 ` Noah Lavine
2011-01-28  3:25                   ` Noah Lavine
2011-01-28  5:13                     ` Michael Lucy
2011-01-28 15:48                   ` Andy Wingo
2011-01-29  3:07                     ` Noah Lavine
2011-01-29  4:15                       ` Michael Lucy [this message]
2011-01-29 11:34                         ` Andy Wingo
2011-01-29 19:37                           ` Noah Lavine
2011-01-30 11:43                             ` Andy Wingo
2011-02-02  0:26                               ` Noah Lavine
2011-02-06 15:31                                 ` Noah Lavine
2011-02-18 22:03                                 ` Andy Wingo
2011-02-23 15:10                                   ` Noah Lavine
2011-03-04 10:52                                     ` Andy Wingo
2011-03-04 13:09                                       ` Noah Lavine
2011-01-29 11:33                       ` Andy Wingo
  -- strict thread matches above, loose matches on Subject: below --
2010-05-27  5:19 Michael Lucy

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='AANLkTimUm_UL9W7EvfoF273U7E7sgOQB8feL-s2=5QfH@mail.gmail.com' \
    --to=michaelglucy@gmail.com \
    --cc=guile-devel@gnu.org \
    --cc=ludo@gnu.org \
    --cc=noah.b.lavine@gmail.com \
    --cc=wingo@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).