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

should Dump \@tied trigger tied methods?

Thread Next
From:
Dave Mitchell
Date:
October 17, 2014 13:45
Subject:
should Dump \@tied trigger tied methods?
Message ID:
20141017134458.GE5204@iabyn.com
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.


-- 
Little fly, thy summer's play my thoughtless hand
has terminated with extreme prejudice.
        (with apologies to William Blake)

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