develooper Front page | perl.perl5.porters | Postings from October 2014

Re: should Dump \@tied trigger tied methods?

Thread Previous | Thread Next
From:
demerphq
Date:
October 17, 2014 14:24
Subject:
Re: should Dump \@tied trigger tied methods?
Message ID:
CANgJU+X=De0p42HLWf+r0njbiMQaHFQ70t1kcZn8p+FVygiE=w@mail.gmail.com
On 17 October 2014 16:20, demerphq <demerphq@gmail.com> wrote:

> On 17 October 2014 15:44, Dave Mitchell <davem@iabyn.com> wrote:
>
>> the following code:
>>
>>     use Devel::Peek;
>>
>>     sub TIEARRAY { bless [] }
>>     my @a;
>>     tie @a, "main";
>>     Dump \@a;
>>
>> gives:
>>
>>     SV = RV(0x8554e8) at 0x8554d8
>>     ....
>>     Can't locate object method "FETCHSIZE" via package "main" at
>> /home/davem/tmp/p line 9.
>>
>>
>> because its triggering a call to FETCHSIZE to find out how many elements
>> it stores so it can dump them.
>>
>> And if there *is* a FETCHSIZE method, then it adds PERL_MAGIC_arylen_p
>> magic to the AV, then dumps individual elements as PVLVs.
>>
>> I think that both of these behaviours is a bug, and for tied AV's, dump
>> should be dumping the first phyiscal N elements stored in it, rather than
>> any tied elements; i.e. if the code is
>>
>>     my @a = (a b c);
>>     tie @a, "main";
>>     Dump \@a;
>>
>> Then dump should display the 'a', 'b' and 'c' SVs
>>
>> If people concur, I'll fix it.
>>
>
> FWIW, I concur. DDS actually uses Object::Deadly to test this kind of
> thing. I suspect we should do the same with Devel::Peek.
>
>
HRm, I had a vague recollection that Object::Deadly did ties, but
apparently not.  Anyway, the point is still valid. DDS actively tests that
it will never call a method during serialization.

Yves

-- 
perl -Mre=debug -e "/just|another|perl|hacker/"

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