in reply to Re: Threads and fork and CLONE, oh my!
in thread Threads and fork and CLONE, oh my!
The benefits of inside-out/flyweight objects have been beat to death on this board and center primarily on the stronger encapsulation of data and the orthogonality to potential property name clashes with super/subclasses. However, the approach needs a unique ID -- and, for reasons lost to history, someone used "$self" (hey, it's unique, right?) as cheaper than generating a unique ID and from there to just the memory address part, and the cargo cult followed.
I think the fundamental storage techinque is sound and using a UUID would fix up the refaddr problem -- though as I said, at the cost of coupling superclasses/subclasses more tightly. It's fine if everything in the class hierarchy is built the same way (e.g. on a blessed scalar with a UUID inside), but one loses the ability to subclass someone else's class (e.g. on CPAN) without caring what kind of blessed reference they used (hash, array, etc.) or whether it changes in some future version. For some, that may be a bigger benefit.
I'd still like to hear people's view on that topic -- whether that is important enough to justify the extra complexity of CLONE . I'd also like to get people's views on whether adding external dependencies on Data::UUID and/or Win32API::GUID are worthwhile or whether some other inline, pure-Perl"unique id" algorithm is preferable (with say, Time::HiRes, process ID, hostname/IP, etc.
-xdg
Code written by xdg and posted on PerlMonks is public domain. It is provided as is with no warranties, express or implied, of any kind. Posted code may not have been tested. Use of posted code is at your own risk.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Threads and fork and CLONE, oh my!
by adrianh (Chancellor) on Aug 17, 2005 at 15:08 UTC | |
by xdg (Monsignor) on Aug 17, 2005 at 15:40 UTC | |
by jdhedden (Deacon) on Sep 16, 2005 at 17:57 UTC | |
by xdg (Monsignor) on Sep 16, 2005 at 18:26 UTC | |
by demerphq (Chancellor) on Nov 15, 2005 at 14:49 UTC | |
by adrianh (Chancellor) on Sep 18, 2005 at 08:28 UTC | |
by demerphq (Chancellor) on Nov 15, 2005 at 14:41 UTC | |
Re^3: Threads and fork and CLONE, oh my!
by dragonchild (Archbishop) on Oct 03, 2005 at 02:42 UTC |