unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Andy Wingo <INVALID.NOREPLY@gnu.org>
To: Andreas Rottmann <a.rottmann@gmx.at>,
	Andy Wingo <wingo@pobox.com>,
	bug-guile@gnu.org
Subject: [bug #31472] Probable psyntax bug with multiple defininitions in the macro expansion
Date: Sun, 27 Feb 2011 12:33:51 +0000	[thread overview]
Message-ID: <20110227-123349.sv20118.5365@savannah.gnu.org> (raw)
In-Reply-To: <20101026-224227.sv12227.22452@savannah.gnu.org>

Follow-up Comment #1, bug #31472 (project guile):

Hi Andreas,

I have thought about this one a fair amount this weekend.  The issues are
twofold.  One, as you note, the modules are getting resolved wrongly -- the
expansion makes the procedure scope "t" in the macro's module, not the
expansion module.  The question is, what should happen?

According to all the hygiene folk I hear from, the (define t #(1 2 3))
shouldn't actually create a binding for "t" in any module.

A simpler case is the following:

  (define-syntax define-x
    (syntax-rules ()
       ((_) (define x 0))))

The issue is, what should happen when you (define-x) ?  Should you later -- in
the REPL, say -- be able to access a binding named "x" in the current module?

Hygiene people say no.  Hygiene people say that since the identifier "x" was
introduced by the macro, it should be visible only within the macro --- and
since it's not used elsewhere in the macro, effectively it's invisible. 
Though you can't really know its extent of course.  And, in Guile, if we were
to gensym a name for it -- a wild thing to think about doing, serializing a
useless (define x_21234113132 0) into a .go file -- it would still take up
"space" in the module (and the .go file), every time you (define-x) you would
be adding useless, inaccessible bindings to your image.  It doesn't seem like
a great idea.

So, unless I misunderstand the issues or am overlooking a solution, I think
that Guile will continue to bind "t" in the expanding module, as indeed
happens in this macro.

The second problem thus "resolved", we need to make the procedure in the
expansion scope its "t" according to the "t" it introduces.  This only happens
when expanding a toplevel sequence -- chi-top-sequence, in psyntax.scm.  I
have recently refactored that procedure to be able to know what bindings it
introduces before going to expand the expressions.  So your mission, should
you choose to accept it, is to distructively mutate the toplevel ribcage
before going in to expand the sub-expressions in chi-top-sequence.

Good luck!

Andy

    _______________________________________________________

Reply to this item at:

  <http://savannah.gnu.org/bugs/?31472>

_______________________________________________
  Message sent via/by Savannah
  http://savannah.gnu.org/




  reply	other threads:[~2011-02-27 12:33 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-10-26 20:42 [bug #31472] Probable psyntax bug with multiple defininitions in the macro expansion Andreas Rottmann
2011-02-27 12:33 ` Andy Wingo [this message]
2011-05-21 13:46   ` Göran Weinholt
2011-06-09 16:48     ` Stefan Israelsson Tampe

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=20110227-123349.sv20118.5365@savannah.gnu.org \
    --to=invalid.noreply@gnu.org \
    --cc=a.rottmann@gmx.at \
    --cc=bug-guile@gnu.org \
    --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).