in reply to Are Addresses From refaddr Unique Across Threads?
One of the points of inside-out objects is that the references do not point to anything used by the inside-out classes. Only the address is used, and nothing else. Your objects rely on the fact they are hash references, and rely on the key __PACKAGE__. This means you are breaking encapsulation. A subclass can fiddle with the internals (by accident) and you are denying your subclasses any implementation that deviates from being a hashref.
Threads within a process all share the same address space.Is that true on every platform? Will that always be true, even in a next version or Perl? I don't think Perl gives you that promise; I would hence not rely on it.
But if you're going to store the keys in the object themselves, why bother with the refaddress of which you aren't sure it's going to work? Just use a random number, and if it's already used in %class_records, pick another one. Or use a counter.
BTW, from your code fragment, I don't understand what the role of $class_objects is.
Of course, the easy way is to upgrade to 5.10. Then you can use fieldhashes, and everything will be done for you.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Are Addresses From refaddr Unique Across Threads?
by ikegami (Patriarch) on Feb 19, 2010 at 21:26 UTC | |
| |
|
Re^2: Are Addresses From refaddr Unique Across Threads?
by BrowserUk (Patriarch) on Feb 15, 2010 at 19:45 UTC |