in reply to Inside Out Classes and the internal Hashes

{ ... sub new { my ($class, $cords) = @_; ... } ... } my $point = PointX->new({x=>3, y=>20});

By passing a hash reference as an argument to your constructor, you are creating and destroying a hash at each object creation just for passing the arguments, which wouldn't be the case if you passed in a list (built => 'with', fat => 'commas'). A lexical hash inside the constructor which takes the arguments is created and allocated once (but its keys and values are cleared when its scope is left).

This is a trivial example of just having 2 items tracked with a single hash. My current application will track around a dozen. I'd prefer not to have a dozen hashes, but I will if it's deemed to be The-Right-Thing (tm).

Check out Anno's Alter package, which is a nice alternative to "traditional" inside-out objects based on lexical hashes. It supports multiple inheritance, doesn't need refaddr, needs no fiddling with DESTROY, objects created that way are garbage-collected in the same way as all perl data types and thread safe. It implements data encapsulation in a most perlish and elegant way.

IMHO, it supersedes and obsoletes the lexical-hash-style inside-out packages. Somebody had to say it...

--shmem

_($_=" "x(1<<5)."?\n".q·/)Oo.  G°\        /
                              /\_¯/(q    /
----------------------------  \__(m.====·.(_("always off the crowd"))."·
");sub _{s./.($e="'Itrs `mnsgdq Gdbj O`qkdq")=~y/"-y/#-z/;$e.e && print}