Randy Kramer
11/1/2007 7:07:00 PM
On Thursday 01 November 2007 12:09 pm, Tim Pease wrote:
> Symbols are never freed during the lifetime of a ruby program. Once
> they are *allocated in the symbol hash table*, they are there forever.
(Emphasis added.)
Thanks, that helps me a lot (I guess I (sometimes) like to know what's going
on behind the scenes). And that helps me understand some of the stuff I was
pondering over a few weeks ago during the discussion of (iirc) references vs.
pointers.
Hmm, thinking of that, maybe you or someone else can confirm a few points:
* one difference between a C pointer and a Ruby reference that I'm "walking
away with" is that the C pointer is stored in a location (and takes up space)
where the programmer can access it (and can notice that it takes up space).
In contrast, a Ruby variable (which is a reference) is not as easily
accessible to the programmer, but it does take up space in the (Ruby's)
symbol hash table.
* in Ruby's symbol hash table, a symbol is stored (in the hash table) with
all the characters that make up the symbol. For example, if I have a
symbol :test, in Ruby's hash table, the string "test" is stored. (I'm
guessing as the key--I presume the value is something that somehow eventually
is translated into a location in memory.)
Is there a way for the programmer to manipulate Ruby's symbol hash table
within Ruby more directly than occurs when defining variables or symbols?
Randy Kramer