unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <wingo@pobox.com>
To: Michael Lucy <MichaelGLucy@Gmail.com>
Cc: guile-devel@gnu.org
Subject: Re: PEG Parser Updates/Questions
Date: Fri, 20 Aug 2010 14:30:04 -0700	[thread overview]
Message-ID: <m38w41rmzn.fsf@unquote.localdomain> (raw)
In-Reply-To: <AANLkTik6gsxEq+0pAz=Et-v496fLuuXBVs9YcVTfd2qF@mail.gmail.com> (Michael Lucy's message of "Fri, 6 Aug 2010 01:40:13 -0500")

Hello, Mr. Lucy!

At some point I might escape the need to apologize at every mail I send,
but until then: sorry for the late response!

On Thu 05 Aug 2010 23:40, Michael Lucy <MichaelGLucy@Gmail.com> writes:

> On Wed, Jul 28, 2010 at 12:13 AM, Michael Lucy <MichaelGLucy@gmail.com> wrote:
>> I've officially eliminated the last define-macro expression.
>>
>> However, I get the feeling that things may not be exactly as desired.
>> The original program made extensive use of functions in building the
>> macros, and I originally tried to replace these with macros.  This
>> turned out to be a little difficult to debug, however (read: I was
>> unable to make the code actually work).  I eventually abandoned this
>> and just made datum->syntax calls.

I'll have to check and see what the deal is. However note that with
procedural macros you can still use helper functions that operate on
syntax objects, destructing them via syntax and building up syntax
objects using `syntax'. Think of a procedural macro as consisting of one
helper function :)

>> The downside is that one doesn't get all the same benefits of
>> referential transparency, so I still have gensyms in the functions
>> etc.  Is this a problem?

Yep! But it probably won't be a big deal to fix.

>> Another question about module namespaces:  I have some syntax that I'd
>> like to be available to code generated by macros in my module, but
>> which I'd rather not export to the user (to avoid clobbering their
>> functions).  Is there a standard way of doing this?

Phil mentioned @ and @@, but the normal case is that things Just Work,
due to the referential-transparency-preserving properties of
syntax-case.

For example:

    (define-module (a)
      #:export (b))

    (define-syntax b
      (lambda (x)
        (syntax-case x ()
          ((_ exp)
           #'(c exp)))))

    (define-syntax c
      (syntax-rules ()
        ((_ exp) (car exp))))

    (define-module (d)
      #:use-module (a))

    (b '(1 2 3))
     => 1

You see that the expansion of `(b '(1 2 3))' in the module `(d)'
produced a reference to `c' -- but `c' is private in the `(a)'
module. Barring the use of datum->syntax, syntax-case macros *scope free
identifiers within the lexical conext and module in which they
appear*. That's what "hygiene" is.

Anyway, I hope to have time to poke this next week. I'm very much
looking forward to having a good PEG parser!

Cheers,

Andy
-- 
http://wingolog.org/



  parent reply	other threads:[~2010-08-20 21:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-07-28  5:13 PEG Parser Updates/Questions Michael Lucy
2010-07-28  5:41 ` No Itisnt
2010-07-28  5:51   ` Michael Lucy
2010-08-06  6:40 ` Michael Lucy
2010-08-16  5:37   ` Michael Lucy
2010-08-20 21:30   ` Andy Wingo [this message]
2010-08-29  7:45     ` Phil
2010-08-30 15:32       ` Andy Wingo

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=m38w41rmzn.fsf@unquote.localdomain \
    --to=wingo@pobox.com \
    --cc=MichaelGLucy@Gmail.com \
    --cc=guile-devel@gnu.org \
    /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).