Hi -- On Fri, 30 Dec 2005, dblack / wobblini.net wrote: > Hi -- > > On Fri, 30 Dec 2005, Steve Litt wrote: > >> On Thursday 29 December 2005 10:16 am, dblack / wobblini.net wrote: >>> >>> Just out of curiosity: can you describe how symbols would work if >>> they weren't surprising? >> >> They wouldn't exist, or they wouldn't be called symbols. If I'm referring >> to >> an instance instead of a value, I could call it &variable as in C, or I >> could >> call it :variable, but in that case I'd call it a reference, not a symbol. > > But it's not a reference; it's an object, of class Symbol. If you do: > > s = :sym > > then the variable s holds a reference to the object :sym, just as when > you do: > > a = [] > > a holds a reference to that array. This assertion by me seems to have been mercifully ignored in subsequent discussion :-) Actually, s = :sym doesn't produce a reference to :sym; rather, s has the actual/immediate value :sym. Anyway, the main (obscured) point was that symbols are not references. > I think one important key to understanding symbol objects is their > immediacy. When you see :sym, it's very similar to seeing an integer. > It *is* the object. What gets done with the object, or what methods > do or do not know how to use it to pry out methods or other things, is > secondary. Here's where the s = :sym example should have been, since otherwise I'm really talking about the literal constructor, which wasn't (i.e., shouldn't have been) the main point. Anyway, I just wanted to ungarble that post a little :-) David -- David A. Black dblack / wobblini.net "Ruby for Rails", from Manning Publications, coming April 2006! http://www.manning.com/books/black