unofficial mirror of bug-guile@gnu.org 
 help / color / mirror / Atom feed
From: Mark H Weaver <mhw@netris.org>
To: Andy Wingo <wingo@pobox.com>
Cc: Guile Bugs <bug-guile@gnu.org>
Subject: Re: `set!' of generated temporary in macro expansion causes warning
Date: Thu, 30 Jun 2011 13:35:13 -0400	[thread overview]
Message-ID: <87zkkz2pf2.fsf@yeeloong.netris.org> (raw)
In-Reply-To: <871uysaln2.fsf@pobox.com> (Andy Wingo's message of "Fri, 17 Jun 2011 10:48:49 +0200")

Hi Andy,

Andy Wingo <wingo@pobox.com> writes:
> p.s.  Regarding hygienically introducing identifiers, I had an idea.
> From a mail I sent to scheme-reports:
>
>     To recap:
>
>        (define-syntax define-const
>          (syntax-rules ()
>            ((_ name val)
>             (define t val)
>             (define-syntax name (syntax-rules () ((_) t))))))
>
>     Guile currently does not make the generated toplevel definition "t" have
>     a fresh name.  It would be nice if it could but it can't be a really
>     random name -- it needs to be predicatable.
>
>     Well why not have the name of "t" be "t" plus some string which depends
>     only on the incoming form -- like its hash value.  (Or the outgoing
>     form; the considerations are different but similar.)

This won't work.  Two identical invocations of the same macro must
generate distinct toplevel variables, in the same way that identical
invocations of the same procedure must generate distinct lexical
variables.  Therefore, the name must depend not only on the form;
identical forms must somehow be made unique.  One possibility is to
include the source code location in addition to (or instead of) the
form.

Furthermore, it is not sufficient to include only one incoming form.  We
must include the entire stack of incoming forms (each annotated to make
them unique).  Suppose macro A invokes macro B twice, and macro B makes
a private top-level variable.  Invoking macro A once should create two
distinct top-level variables.

If these names were constructed from the stack of source code locations,
this could also be a great help in generating useful error messages
involving these generated top-level variables.

    Best,
     Mark


>     That way you do preserve the "compatible recompilation" aspect, trading
>     off true secrecy, but hey.  Oh well.
>
> This would obviously be for master / 2.2 and not 2.0.



  reply	other threads:[~2011-06-30 17:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-06-13 10:10 `set!' of generated temporary in macro expansion causes warning Andreas Rottmann
     [not found] ` <BANLkTin87s-9YKi+LyAmH+2=HGVYq7nFKQ@mail.gmail.com>
2011-06-13 12:10   ` Andreas Rottmann
     [not found]     ` <BANLkTimgdKtNFf8xj7DTUpSLmbQZtQZ0Xw@mail.gmail.com>
2011-06-13 13:25       ` Andreas Rottmann
2011-06-17  8:48     ` Andy Wingo
2011-06-30 17:35       ` Mark H Weaver [this message]
2011-06-30 18:12         ` Andy Wingo
2011-06-13 13:50   ` Fwd: " 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=87zkkz2pf2.fsf@yeeloong.netris.org \
    --to=mhw@netris.org \
    --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).