in reply to Re: Re: Re: Re: Class::Interface -- isa() Considered Harmful
in thread Class::Interface -- isa() Considered Harmful
In your example, $h is not a tied hash. $h is a blessed reference to an object that is used to store data for the tied hash. The tied hash is %new_hash.
For a better example than the one you are presenting:
use Scalar::Util qw(reftype); tie(%hash, "ScalarHash"); function_that_expects_a_hash_reference(\%hash); sub function_that_expects_a_hash_reference { my($hash_ref) = @_; reftype($hash_ref) eq 'HASH' or die "CALLED WITHOUT A HASH REFERENCE!\n"; ... $hash_ref->{...} ... } package ScalarHash; sub TIEHASH { bless \(my $foo), $_[0] }
As I pointed out in the node that you were responding to, you are confusing Perl object interfaces (the ability to use a scalar as if it were a hash reference), and Perl blessed reference methods (the ability to use a particular method with an object).
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Re: Re: Re: Re: Class::Interface -- isa() Considered Harmful
by chromatic (Archbishop) on Jan 18, 2003 at 01:11 UTC |