object id, objectspace, ip addresses

Z

zuzu

what determines an object id?

the purpose of an object id is so that all objects in memory /
objectspace are uniquely identifiable, yes?

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

the more i think of that, the more i do favor existing infrastructure
and not reinventing the wheel.

-z
 
J

Joe Cheng

zuzu said:
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.

IP numbers are not actually unique across the Internet. For example,
most intranets use 192.168.0.0/24, so there are probably many hundreds
of thousands of computers in the world right now with an IP address of
192.168.0.2. The vast majority of them are probably connected to the
Internet (though hopefully none of them are directly connected). So
depending on what your app is, you could very well end up with many
clients generating ID's based off the same IP address.

Anyway, this is what GUID/UUID generation libraries are for. I don't
know how they work on other platforms, but the Windows-provided GUID
generator uses MAC address, timestamp, and a counter or two, and creates
128-bit GUIDs:

http://tinyurl.com/49h3r
the more i think of that, the more i do favor existing infrastructure
and not reinventing the wheel.

How about this:
http://raa.ruby-lang.org/project/ruby-guid/
 
R

Robert Klemme

zuzu said:
what determines an object id?

the purpose of an object id is so that all objects in memory /
objectspace are uniquely identifiable, yes?

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.

I don't know what you're aiming at, but if you had a seamless (implicit)
distribution of the ruby interpreter across multiple hosts, that runtime
environment would ensure that ids stay unique and it would provide means
for address (or id) resolution and method invocation. You probably
wouldn't know where an object lives - but you wouldn't have to care
(keeping file IO etc. aside for the moment).

If you have explicit distribution (as with DRB) you typically know when
you access a remote object or a local object although a DRB method call
looks like a normal call. All objects that you can reference live in the
local object space (and are unique) but some of them are just proxies that
send your request through the network. Typically you know which are the
proxies because you have to connect to remote objects yourself.
perhaps that's it? e.g. 63.151.230.81+0x401b499c

the more i think of that, the more i do favor existing infrastructure
and not reinventing the wheel.

Again, what are you aiming at?

Regards

robert
 
B

Brian Candler

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.
 
T

trans. (T. Onoma)

what determines an object id?

the purpose of an object id is so that all objects in memory /
objectspace are uniquely identifiable, yes?

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

the more i think of that, the more i do favor existing infrastructure
and not reinventing the wheel.

Highly recommend:

http://www.taguri.org/

BTW: Reading this I see visions of a global ObjectSpace marshalled about on
dRuby. Am I crazy?

T.
 
Z

zuzu

ok, yes, everyone seems to immediately think of drb/rinda because
that's what already exists. true.

i will give it a second look after reading through the documents for
plan9; but the idea is quite similar -- "objectspace" rather than
"namespace"; or much like the gnu arch version control system where
each file reiceives a uid.

the goal is more for automatic acquisition and customization of
objects to assemble into "applications" in a p2p/"open systems"
fashion. or from the gnu arch perspective, where at least every Class
implementation is uniquely identifiable by peer host. no longer would
a centralized ruby object library need centralized maintainence, but
rather something like linux distributions (or more like package
management / gentoo *meta*distributions) in a p2p fashion.

drb/rinda *sorta* (but not really) does this, to my understanding.
i think the motivation behind drb/rinda is correct, but i'm
questioning the theory behind its implementation in favor of something
like carl hewitt's 'actors model'+'open systems'.

so that's what i'm thinking, anyway.

-z
 
W

why the lucky stiff

trans. (T. Onoma) said:
YAML uses taguri for this very purpose. You can create unique
identifiers for your Ruby classes in YAML. See the YAML documentation
<http://yaml4r.sourceforge.net/doc/>, especially the section on "Type
Families" for information.

As for referring to unique objects, it's probably best to use some sort
of URI, though not necessarily taguri. I keep an object with site news
at <http://whytheluckystiff.net/index.yaml>. I'd probably use the HTTP
address to refer to the object rather than a taguri, simply because the
URL gives you the means for accessing the object immediately.

_why
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,580
Members
45,054
Latest member
TrimKetoBoost

Latest Threads

Top