From: timsuth@... (Tim Sutherland) Date: 2005-01-11T09:06:20+09:00 Subject: Re: Immediate values In article <20050110211912.GA75928@topi.cc>, why the lucky stiff wrote: [...] >Hi, Ruth. So, when someone on the list uses uppercase VALUE, they are >refering to an object's symbol table id. The symbol table being the >global dictionary that pairs up a unique id with pointers to the actual >objects. VALUE is a C typedef. [...] There is no such global dictionary, all the information is encoded in the VALUE. See http://www.rubygarden.org/ruby?GCAndExtensions: Ruby objects are represented by VALUE in the Ruby C API. This is a typedef for unsigned long. The value 0 is used for false and 4 is used for nil. Otherwise, if the two least significant bits are 00 it is a pointer to a structure on the heap which represents the Ruby object. (i.e. if "value & 0x03 == 0.") Other values are immediate objects or special constants (small integers, symbols, true). This works because the structures are always quad-aligned in memory. (So the pointer is always a multiple of 4, i.e. has lower bits 00.) Then for example FIX2INT converts a Fixnum to a C int by right-shifting the VALUE.