On Sep 9, 2009, at 7:51 AM, Andre van Tonder wrote:
> This, however, makes it difficult to write program transformers (for
> example
> macro expanders), that need to insert generated symbols for which the
> requirement is that they cannot be typed in user programs.
Is that the requirement? If so, Chez is already in violation of this:
> (gensym)
#{g0 f3s6pdjhhzxupwds-a}
> (define gensyms-readable
(lambda ()
(let ((g (gensym))
(p (open-output-string)))
(write g p)
(let ((r (open-input-string (get-output-string p))))
(eq? (read r) g)))))
> (gensyms-readable)
#t
The actual requirement for the use of gensyms in this situation is
that a gensym must not be eq? to any other symbol which already exists.
In practice, I think that the use of gensyms in macro transformers is
a bad design decision. Using a gensym requires carrying around another
table (or using symbol properties) to hold information about the
original lexical context. Using an identifier type of some kind solves
these problems, preserving both the original name of the identifier
and a pointer to the lexical context it was originally used in.
--
Brian Mastenbrook
[email protected]
http://brian.mastenbrook.net/
_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss