[r6rs-discuss] bound identifier predicate
Aaron W. Hsu
arcfide at sacrideo.us
Sun Jun 21 22:08:58 EDT 2009
On Sun, 21 Jun 2009 20:31:11 -0400, Ramana Kumar <ramana.kumar at gmail.com>
> If you could create an identifier whose wrap was known to be empty
> (i.e. had no substitutions), then your trick with free-identifier=?
> would work for imports and top-level definitions as well as
> lower-level (e.g. let) bindings. That's why I asked whether such a
> guarantee of an empty wrap could be made for the results of
I don't know if this is possible, but using EVAL on a null environment
would work, I think, to achieve a syntax which was not wrapped with any of
the other bindings. However, I don't think this will work with the
'free-identifier=?' technique for determining whether something is bound
The semantics of 'free-identifier=?' is to assume that there is a
top-level environment in which all bindings are considered to be bound,
and then to examine the two syntaxes given, and determine whether the two
would reference the same location given that they existed as free
identifiers in the scope wherein the call to 'free-identifier=?' occurs.
If you are given one identifier at some scope, and then construct another
identifier created as a top-level scoped variable with the same name or
form as the other identifier, applying 'free-identifier=?' to these two
syntaxes gives two possible results:
1) If the original syntax is bound to a lexical variable, then the two
variables must by definition reference different locations, and therefore,
the call must return false.
2) If the original syntax is not bound to any lexical variable, then the
semantics of 'free-identifier=?' requires that we assume that the
identifier is bound at the top-level, and since the wraps on the two names
are now the same, the call must return true.
That is, it is because we have this top-level break point that we can
catch bindings when they occur at any internal scope that is more narrow
than the top-level. If we were to be given a syntax wrapped in a null
environment, it would never be 'free-identifier=?' to anything, and both
of the two cases above must return false, because it will never happen
that the two identifiers reference the same location. At least, this is
how it seems to me in my reading. I would appreciate any correction on my
understanding of how this works.
To answer your other question, about 'generate-temporaries', I also don't
think that this will work. Reading the R6RS definition of
'generate-temporaries', I am inclined to think that there is no guarantee
made about the wrapping, and thus, one can't guarantee how the wrapping
occurs there. Also, what exactly is a "null" wrapping? How would it be
meaningful with regards to 'free-identifier=?'?.
Aaron W. Hsu
Of all tyrannies, a tyranny sincerely exercised for the good of its
victims may be the most oppressive. -- C. S. Lewis
More information about the r6rs-discuss