develooper Front page | perl.perl5.porters | Postings from February 2013

Why does Perl use a full blown scope for dereferencing?

Thread Next
From:
Peter Rabbitson
Date:
February 28, 2013 08:43
Subject:
Why does Perl use a full blown scope for dereferencing?
Message ID:
20130228084342.GA22503@rabbit.us
I came across what seems like a deficiency in the optimiser. Why is a 
new scope set-up for anything but the simplest form of direct single-var 
dereference?

perl -MO=Terse -e 'my $x = [1]; my $y = { x => $x }; warn "Follows terse deref"; warn @$x; warn "Follows verbose deref"; warn @{$x}; warn "Follows deref of hash value"; warn @{$y->{x}}'

(top of program snipped away)

    LISTOP (0x83e3c54) warn [3] 
        OP (0x83e3c38) pushmark 
        SVOP (0x83e3c78) const [15] PV (0x83f92e8) "Follows terse deref" 
    COP (0x843a22c) nextstate 
    LISTOP (0x843a280) warn [5] 
        OP (0x843a264) pushmark 
        UNOP (0x843a2a4) rv2av [4] 
            OP (0x83e3bc8) padsv [1] 
    COP (0x843a190) nextstate 
    LISTOP (0x843a1e4) warn [6] 
        OP (0x843a1c8) pushmark 
        SVOP (0x843a208) const [16] PV (0x83f9298) "Follows verbose deref" 
    COP (0x843a078) nextstate 
    LISTOP (0x843a0cc) warn [8] 
        OP (0x843a0b0) pushmark 
        UNOP (0x843a0f0) rv2av [7] 
            LISTOP (0x843a110) scope                       <----- why?
                OP (0x843a134) null [182] 
                OP (0x843a16c) padsv [1] 
    COP (0x8439fdc) nextstate 
    LISTOP (0x843a030) warn [9] 
        OP (0x843a014) pushmark 
        SVOP (0x843a054) const [17] PV (0x85201fc) "Follows deref of hash value" 
    COP (0x849562c) nextstate 
    LISTOP (0x8495680) warn [12] 
        OP (0x8495664) pushmark 
        UNOP (0x8439ed8) rv2av [11] 
            LISTOP (0x8439ef8) scope                       <----- why?
                OP (0x8439f1c) null [182] 
                BINOP (0x8439f54) helem 
                    UNOP (0x8439f78) rv2hv [10] 
                        OP (0x8439fb8) padsv [2] 
                    SVOP (0x8439f98) const [18] PV (0x8526668) "x" 


Cheers

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