in reply to Blessing into the same package in class (object) and tie contexts

This is not standard operating procedure, as far as I know.
my $p = MyPackage->new(); $$p{Hello} = "world"; print $p->to_string, "\n";
Requiring users of MyPackage objects to know that the objects are hashrefs isn't good OO (no encapsulation). And dereferencing the hashref to use it as a tied hash seems convoluted and unnatural e.g. compared to an interface like
tie my %h, MyPackage; $h{Hello} = "world"; # use tied to call object methods print tied(%h)->to_string, "\n"; # -> 'Hello World'
i.e. in the example you've given there doesn't seem to be a case for going beyond the standard tied hash semantics.

Replies are listed 'Best First'.
Re^2: Blessing into the same package in class (object) and tie contexts
by ryangies (Initiate) on Mar 28, 2008 at 02:05 UTC

    I suspected this was not common and appreciate the validation. I have run in to a few stack dumps with different variations on this theme and am concerned that there might be a critical no-no which I'm unaware of.