[plt-scheme] immutable strings vs. uninterned symbols
At Tue, 6 Jun 2006 12:20:55 -0400, Doug Orleans wrote:
> (Would it be possible to
> make a symbol->immutable-string that was constant time?)
Not with the current representations, because symbols use UTF-8 and
strings use UTF-32.
> But this makes me wonder: does a symbol
> take up more space than a string?
Usually less, due to the UTF-8 encoding, and due to an indirection in
the string representation (where the string's vector of characters is a
separate block of memory.) But a string of a few Chinese characters
would be more compact than the corresponding symbol, due to the UTF-8
encoding of symbols.
> Except that literal strings are interned in
> Java, so "foo" == "foo" is always true but (eq? "foo" "foo") is usually
> false. (It's unspecified by R5RS, but is it guaranteed by MzScheme?)
I don't think MzScheme is any better specified than R6RS on this point,
and it's something we should think about more.
Matthew