Documentation
A Symbol
. This is essentially a String
, but with different
performance characteristics:
-
O(n)
creation time (usinginsert
) -
O(1)
equality comparison. -
O(1)
comparison (in practice). The result ofcompare
is independent of evaluation order.
It is currently implemented as follows.
- Each symbol contains a unique integer, which allows
O(1)
comparison. - Each symbol contains an infinite chain of hashes, these are used for comparison. In practice, it is very rare that more than the first of those hashes is ever evaluated. The first hash is cached, so that most comparisons will not need any indirections.
- The
String
representation of the symbol. Useshow
to return it. At any time, there will be only one symbol of a given name in memory.