bug-guile
[Top][All Lists]
Advanced

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

Re: Uninterned symbols


From: Dirk Herrmann
Subject: Re: Uninterned symbols
Date: Fri, 18 May 2001 10:53:30 +0200 (MEST)

On Thu, 17 May 2001, Martin Grabmueller wrote:

> > From: Dirk Herrmann <address@hidden>
> > 
> > Maybe I am too blind to see, but:  What are the problems with providing
> > unique symbols?  We have one single hash table in guile, thus it should be
> > possible to determine whether a symbol exists or not.  Using some prefix
> > (say, 'gensym-') an an incrementally increased number as postfix, it
> > should be possible to come quickly to a symbol that has never been used
> > before.  In the context of threads, you would have to lock the symbol
> > table during the search for a new symbol.
> 
> Writing gensym the way you propose makes it possible to create symbols
> which are unique as far as the already existing symbols are concerned.
> But what about symbols which are created after gensym'ing a symbol?
> Consider this (old behaviour):
> 
> guile> (define s (gensym))
> guile> s
> g0
> guile> (eq? s (string->symbol "g0"))
> #t
> 
> With my patch, the symbol made by string->symbol will not be eq? to
> the gensym'ed one, even though it looks the same.

OK, got that :-)

> > All other suggestions seem strange to me:  Why add the concept of
> > uninterned symbols?  How can two uninterned symbols be eq?, how do you
> > print them uniquely (seems impossible:  with string->symbol you should be
> > able to create any interned symbol you like and make it look like an
> > uninterened one.), and if you want to be able to read the same uninterened
> > symbols twice, you will at some time want to make sure that you get an
> > uninterned symbol that was never unsed before, which leads us to
> > un^2interned symbols, which leads us to un^3interned symbols etc.
> 
> Well, that's right.  It is of course not possible to create ``forever
> uninterned'' symbols.  But on the other hand, I think it should be
> possible to create symbols which could not possible clash with normal
> symbols, for example for writing macros or translators.
> 
> So maybe we should dump printing/reading of uninterned symbols, but
> keep them for gensym?

Yes, that seems to make sense.  Uninterned symbols could be printed, but
we should be careful when providing means to read them.  Maybe it is best
not to provide a means to read them at all:  Since they can only be
created using gensym, the actual content of the symbol's name is
irrelevant for guile, isn't it?  If such symbols are given a name is a
means to help debugging.  Thus, an uninterned symbol could be read by:
  #,(gensym)
and any references should be relative references, as Marius has explained.

Best regards,
Dirk Herrmann




reply via email to

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