Matt Todd
7/29/2006 4:01:00 AM
Think of a uniquely identifiable, primary key in a database. You would
only refer to that row in that table with that one unique identifier,
right? Imagine that that id is 20. 20 is a pretty arbitrary value, and
can mean 20 people, 20 dollars, 20 minutes past 8, or even 20 the
number itself. That said, the meaning is determined by the context and
intention. Computers don't care too much about intention, and context
only when it has to, so 20 is what it is: a symbol referring to
something. In some cases, a string, in others, a number, and in fewer
circumstances, a symbol (in Ruby).
So, looking at 20 as a symbol (which would be created like... :"20"),
we'd be able to say that this symbol can represent anything, but it is
still the same thing. There is no need to create new instances of it
for the different contexts, really, because it still means nothing
apart from the context and the intention.
Back at the table, we can say that we want to mess with the row
identified by 20. This arbitrary value does not necessarily have an
immediate meaning on the rest of the data (in this example), but it
has meaning in that it identifies it. So, 20 can identify it in this
instance, and it won't in others.
But, what I really want to show is that the symbol, :"20", in ruby, is
always considered the symbol 20, and is not unique in any
circumstances. You mention the symbol :"20", and you will always use
the same symbol (as can be seen by its object id). It is all the same,
but, again, the context is what distinguishes its inherent value.
Of course, this is clear in my head: I hope I described it plainly
enough for you, though I feel somehow that I might not have.
M.T.