[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: A different approach
On 7/19/05, Jens Axel Søgaard <jensaxel@xxxxxxxxxxxx> wrote:
> felix winkelmann wrote:
> > Uninterned symbols are (currently) not provided by standard Scheme,
> > and can be simulated by some magic prefix in portable code.
> Nevertheless, the section eqv? has the following note on symbols:
> The eqv? procedure returns #t if:
> * obj1 and obj2 are both symbols and
> (string=? (symbol->string obj1)
> (symbol->string obj2))
> ===> #t
> Note: This assumes that neither obj1 nor obj2 is an
> ``uninterned symbol'' as alluded to in section 6.3.3. This report does
> not presume to specify the behavior of eqv? on
> implementation-dependent extensions.
Hey, another little piece of R5RS that I didn't know...
> Since some implementation do have uninterned symbols, it implies
> that it isn't great style to rely on the above.
Well, I'm usually very careful with broad "isn't great style"
symbols do in fact complicate the (IMHO rather handy) assumption that
symbol->string and string->symbol 1:1 relationship. Gensyms are an
hack (used in 99% of all cases for "defmacro"-style macro programming). In fact,
I'd rather see a "(genguid)" than a "(gensym)" :-).
The problem is that I've seen numerous bodies of code (object-systems,
module systems, ...) that depend on some kind of "symbol-append" function and
convert back and forth between symbols and strings. In these cases a
is required as uninterned symbols may lead to unexpected things.