develooper Front page | perl.perl5.porters | Postings from November 1999

Re: [ID 19991118.005] Pseudohashes confuse tie()

Thread Previous | Thread Next
From:
M.J.T. Guy
Date:
November 19, 1999 09:00
Subject:
Re: [ID 19991118.005] Pseudohashes confuse tie()
Message ID:
E11orOS-0001cc-00@taurus.cus.cam.ac.uk
Nick Ing-Simmons <nick@ing-simmons.net> wrote
> Treating a tied ARRAY as a hash should trigger the pseudo hash code.
> (I gave this a passing thought when doing TIEARRAY fixes.)

But that doesn't work, as my original example showed.    The problem is
that TIEARRAY gets called instead of TIEHASH.

What I presume is happening, without having done much research, is that
when you do

        tie %$avhv, ...

the % dereference correctly understands about the pseudo-hash case,
and stacks the AV instead of an HV.     But it leaves no indication
that this reference should "really" be thought of as a hash.    So
the tie code just tests the reference type and calls TIEARRAY.

> Likewise a tied HASH should be usable as the index hash.
> Now whether either _works_ is a different story - anyone want to 
> write a t/*.t type testcase?

The latter already has a test case in t/op/avhv.t, presumably by yours
truly.    I only discovered this after writing my own test.  :-(


Mike Guy

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About