Implementation of Symbols

Ok, I’m sure this one has been addressed ump-teen times, but everything
I read,
at least on the rails side, puts symbols in the ‘magic’ space where you
don’t need
to know how they’re implemented–or what they are for that matter–you
just need
to know how to use them.

Anyway, I’ve done a bit of programming in C so understanding it in those
terms isn’t
going to hurt too much… can anyone explain?

So far, the most elegant explanation comes from a discussion on LISP:

“Symbol type: Symbols are effectively pointers to strings stored in a
hash table. So you can test equality by comparing a pointer, instead of
comparing each character.”

from: Revenge of the Nerds

Is this relevant?

-Michael Cowden
StoryRight.com
[email protected]
(443) 519-8662

On Sun, Jan 28, 2007 at 02:20:39AM +0900, Michael Cowden wrote:

“Symbol type: Symbols are effectively pointers to strings stored in a hash table. So you can test equality by comparing a pointer, instead of comparing each character.”

Yeah, pretty much. If you really want to see, you can check out some of
the code in parse.c in and around the function rb_intern.

Thanks, I’m taking a look at it… it appears to handle all the cases
for
global, instance variables, constants, etc.
But I’m not finding where it references a leading ‘:’ on first
glance…
http://www.ruby-doc.org/doxygen/current/parse_8c-source.html

Can you give me a pointer? sorry for the pun

-Michael Cowden
StoryRight.com
[email protected]
(443) 519-8662
----- Original Message -----
From: “Logan C.” [email protected]
To: “ruby-talk ML” [email protected]
Sent: Saturday, January 27, 2007 12:40 PM
Subject: Re: Implementation of Symbols…