Lisp for Java Users: Symbols

Numbers are good, but we also needs words. Lisp uses Symbols for all identifiers, function names and variable names. A Symbol is similar to a String but we will take care that only one Symbol is created for any name. Here is a basic definition of a Symbol class:

public class Symbol { private final String name; protected Symbol (final String name) { this.name = name; } public String getName () { return name; } @Override public String toString () { return name; } }

Obviously, the getName method could be eliminated since it does the same thing as toString, but that would be bad form since the methods really mean something quite different.

‚Äč