The wikipedia entry on Symbol tables is a good reference:
http://en.wikipedia.org/wiki/Symbol_table
But as I try to understand symbols in Ruby and how they are represented in the Array of Symbols (returned by the Symbol.all_symbols
method),
I'm wondering whether Ruby's approach to the symbol table has any important differences from other languages?
Ruby doesn't really have a "symbol table" in that sense. It has bindings, and symbols (what lispers call atoms) but it isn't really doing it the way that article describes.
So in answer to your question: it isn't so much that ruby has the same thing done differently, but rather that it does two different things (
:xxx
notation --> unique ids and bindings in scopes) and uses similar / overlapping terminology for them.To clarify:
The article you link to gives the conventional definition of a symbol table, to wit
But this isn't what ruby's symbol table does. It just provides a globally unique identity for a certain class of objects which can be written as
:something
in the source code, including things like:+
and:"Hi bob!"
which aren't identifiers. Also, merely using an identifier will not create a corresponding symbol. And finally, none of the information listed in the passage above is stored in ruby's list of symbols.It's a coincidence of naming, and reading that article will not help you understand ruby's symbols.