Kawa: Compiling Scheme to Java
1.3 Symbols
Symbols represent names, and do not need much functionality.
Scheme needs to be able to convert them to and from strings,
and they need to be "interned" (which means that there is a global
table to ensure that there is a unique symbol for a given string).
Symbols are immutable and have no accessible internal structure.
Currently, Scheme symbols are implemented using a Kawa-specific
Symbol class.
I am planning to re-implement symbols to use the the
standard Java String class, which supports an intern
operator. Note that the Java String class implements
immutable strings, and is therefore cannot be used to implement
Scheme strings. However, it makes sense to use it to implement symbols,
since the way Scheme symbols are used is very similar to how
Java Strings are used. While Kawa currently assumes a Java
implementation corresponding to version 1.0 of JDK (Sun's Java Development
Kit), a future version will
depend on JDK 1.1 features. One such new 1.1 feature is that
literal Java Strings will be required to be automatically
interned. This will make it even more appealing to use String
to implement Scheme symbols.