On Sun, Oct 13, 2002 at 07:29:15PM +0900, Gavin Sinclair wrote:
> All my objects seem to start somewhere around 13000000!
> 
> It was interesting, but I don't see how the ID of an object can be a pointer,
> in the traditional sense.

Why not? It would be very efficient to be able to take an object ID and
immediately locate the data structure representing the object.

You can't manipulate object IDs in the language (e.g. increment them) so
it's safe from user interference.

> I'm interested in this,
> and this might give me my first reason to examine the source code.

I just found a good explanation of the C structures here:
http://www.rubycentral.com/book/ext_ruby.html

"As we said above, immediate values are not pointers: Fixnum, Symbol, true,
false, and nil are stored directly in VALUE.

Fixnum values are stored as 31-bit numbers[Or 63-bit on wider CPU
architectures.] that are formed by shifting the original number left 1 bit
and then setting the least significant bit (bit 0) to `1.'' When VALUE is
used as a pointer to a specific Ruby structure, it is guaranteed always to
have an LSB of zero; the other immediate values also have LSBs of zero.
Thus, a simple bit test can tell you whether or not you have a Fixnum."

I can't see it saying explicitly that the VALUE is also the object.id, but
it seems pretty clear from the above.

Regards,

Brian.