Brian Candler
10/5/2004 8:52:00 AM
On Tue, Oct 05, 2004 at 10:42:46AM +0900, zuzu wrote:
> what determines an object id?
For most objects, it's just the address in memory of the datastructure for
that object.
There's a trick which uses the property that on a 16-bit or larger machine,
memory addresses for word-aligned objects are always even. So the odd object
ids are assigned special duty as ids for Fixnums:
irb(main):004:0> 0.id
=> 1
irb(main):005:0> 1.id
=> 3
irb(main):006:0> 2.id
=> 5
and some low even object ids are reserved:
irb(main):001:0> nil.id
=> 4
irb(main):002:0> true.id
=> 2
irb(main):003:0> false.id
=> 0
> i am curious as to, if ruby objectspace were extended beyond localhost
> -- if multiple users were to *share* an objectspace, how to maintain
> uniquely identifiable objects just as IP numbers do on the internet.
>
> perhaps that's it? e.g. 63.151.230.81+0x401b499c
Or create a local proxy object, which has its own id, but is tied to some
remote object by means of its instance variables (which might contain the
remote IP address and port, for example). That's what you'll get if you use
drb.
> the more i think of that, the more i do favor existing infrastructure
> and not reinventing the wheel.
Use drb :-)
Regards,
Brian.