guile-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

mark uniqueness (Was: Re: syntax-local-binding)


From: Andy Wingo
Subject: mark uniqueness (Was: Re: syntax-local-binding)
Date: Tue, 24 Jan 2012 21:28:50 +0100
User-agent: Gnus/5.13 (Gnus v5.13) Emacs/23.3 (gnu/linux)

On Tue 24 Jan 2012 14:25, Mark H Weaver <address@hidden> writes:

> I don't see why we need universally-unique gensyms
> I've already explained why they are not needed
> for macros compiled in another session.

Ah, I forgot to reply to that.  I found it:

On Mon 16 Jan 2012 14:28, Mark H Weaver <address@hidden> writes:

> The reason it has not been a problem with macros is that, within a
> top-level macro (which are the only ones used across Guile sessions),
> the only syntax-objects that can be meaningfully _introduced_ into the
> expansion are top-level/module bindings.  But these bindings have no
> associated labels or gensyms, because they're not in the wrap.
>
> See how this is a problem now where it wasn't before?
> Or am I missing something?

Either you are missing something, or I am, or both of us -- that much is
clear ;-)

Psyntax associates marks with every identifier.  Two identifiers are
equal if they are symbolically equal, and they have the same marks.  It
would break hygiene if two identifiers that didn't come from the same
place accidentally had the same marks.

A fresh mark is placed on syntax returned from a macro expander, if the
syntax was not present in the input.  An easy way to do this would be
simply:

  (define-syntax-rule (fresh-identifier)
    #'x)
  (define my-id (fresh-identifier))

All you need to do is to introduce that binding into a macro, and you
might alias some other binding, because you have serialized the symbol
and marks into a compiled file.

This is admittedly far-fetched.  But it can happen, and at the
top-level.  For example, our old friend:

  (define-syntax-rule (define-const x val)
    (begin
      (define t val)
      (define-syntax x (identifier-syntax t))))

Here, `t' will have a fresh mark.

Now, if in one compilation unit, I do:

  (define-const x 10)

And in another, I do:

  (let ((t 20))
    x) => ?

You would expect the result to be 20.  But I think it could be 20, if
the marks on the two "t"s happened to collide.

Am I missing something? :-)

Andy
-- 
http://wingolog.org/



reply via email to

[Prev in Thread] Current Thread [Next in Thread]