On Wed, 09 Sep 2009 10:42:52 -0400, Brian Mastenbrook  
<[email protected]> wrote:

> 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:

This isn't exactly true.

>  > (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

This only occurs if you first generate a printed representation for the  
gensym, which, by definition, means that it can be written by the user or  
anything else to get that same symbol. This situation will not arise if  
you never print the gensym or grab its representation. Because the actual  
representation of the symbol is never generated until the moment it is  
needed, you are very unlikely to run into any conflicts. EQ? comparisons  
and the like should not cause this sort of representation generation, so  
you're pretty safe, especially within a given single machine.

> 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.

It also should not be eq? to future symbols that are created. Indeed, on  
should not in general be able to create a symbol collision. It is always  
theoretically possible for this to happen.

        Aaron W. Hsu

-- 
Of all tyrannies, a tyranny sincerely exercised for the good of its  
victims may be the most oppressive. -- C. S. Lewis

_______________________________________________
r6rs-discuss mailing list
[email protected]
http://lists.r6rs.org/cgi-bin/mailman/listinfo/r6rs-discuss

Reply via email to