# Implementation of Symbols

**URL:** <https://www.ruby-forum.com/t/implementation-of-symbols/83613>\
**Category:** Ruby\
**Created:** [January 27, 2007, 6:21pm UTC](https://www.ruby-forum.com/t/implementation-of-symbols/83613 "2007-01-27T18:21:16Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael\_Cowden](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@Michael\_Cowden](https://www.ruby-forum.com/u/Michael_Cowden)\
**Post date:** [January 27, 2007, 6:21pm UTC](https://www.ruby-forum.com/t/implementation-of-symbols/83613/1 "2007-01-27T18:21:16Z")

</div>

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](http://www.paulgraham.com/icad.html)

Is this relevant?

-Michael Cowden  
[StoryRight.com](http://StoryRight.com)  
removed\_email\_address@domain.invalid  
(443) 519-8662

---

<div class="post-metadata">

**Author:** ![Michael\_Cowden](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@Michael\_Cowden](https://www.ruby-forum.com/u/Michael_Cowden)\
**Post date:** [January 27, 2007, 6:40pm UTC](https://www.ruby-forum.com/t/implementation-of-symbols/83613/2 "2007-01-27T18:40:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Michael\_Cowden](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/ea666f/32.png) [@Michael\_Cowden](https://www.ruby-forum.com/u/Michael_Cowden)\
**Post date:** [January 27, 2007, 6:54pm UTC](https://www.ruby-forum.com/t/implementation-of-symbols/83613/3 "2007-01-27T18:54:01Z")

</div>

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](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](http://StoryRight.com)  
removed\_email\_address@domain.invalid  
(443) 519-8662  
----- Original Message -----  
From: “Logan C.” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
To: “ruby-talk ML” [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid)  
Sent: Saturday, January 27, 2007 12:40 PM  
Subject: Re: Implementation of Symbols…
