[plt-scheme] immutable strings vs. uninterned symbols

From: Carl Eastlund (carl.eastlund at gmail.com)
Date: Tue Jun 6 09:22:59 EDT 2006

On 6/6/06, Matthias Felleisen <matthias at ccs.neu.edu> wrote:
>  > (string-append "hello" " world")
> "hello world"
>  >
> You can't do this with a symbol. -- Matthias

Sure we can.

> (define (symbol-append one two)
     (string-append (symbol->string one) (symbol->string two))))
> (symbol-append (string->uninterned-symbol "hello")
                 (string->uninterned-symbol "world"))

It's not Doug's fault we don't provide the symbol-append function, but
clearly it can be done.

I think the real answer is:  just about anything you can do with one,
you can do with the other, though with uninterned symbols you're
probably paying for a few extra hash table operations (to look up or
create the symbol/string associations).

Carl Eastlund
"Cynical, but technically correct."

Posted on the users mailing list.