Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^8: Does @{ } copy arrays?

by QM (Parson)
on Oct 29, 2009 at 16:36 UTC ( #803981=note: print w/replies, xml ) Need Help??

in reply to Re^7: Does @{ } copy arrays?
in thread Does @{ } copy arrays?

Can you provide the decoder ring for things like "sKRM*/1"?

Quantum Mechanics: The dreams stuff is made of

Replies are listed 'Best First'.
Re^9: Does @{ } copy arrays?
by ikegami (Pope) on Oct 29, 2009 at 16:47 UTC

    B::Concise lists what opcode flag each letter represents. "M"odifiable is the relevant one here.

    Interesting tidbit:

    As an optimisation, lvalue subs weren't making arylen as Modifiable.

    $ perl -MO=Concise,-exec,f -e'sub f :lvalue { $#a }' 2>&1 | grep av2ar +ylen 4 <1> av2arylen sK/1

    My patch relied on that flag, so it was buggy. The second patch I mentioned made lvalue subs mark arylen as Modifiable.

      OK, I think I understand most of those examples.

      Except foo($#a) has me scratching my head. It's marked modifiable, but it's not a reference (at least not obvious to me). Maybe this is the older, darker magic of the aliasing involved with @_ in subs? (Personally, I avoid coding in such an implicit way, preferring to catch the passed arguments explicitly.)

      I went back an read most of the thread, and, while much of the discussion was over my head, it seems that those in the know are trying to fix it appropriately (or have already done so).

      Thanks to all for a mind-expanding discussion.

      Quantum Mechanics: The dreams stuff is made of

        Params are passed by reference. The elements of @_ are aliased to the arguments passed.
        >perl -le"sub f { $_[0]=456; } $x=123; f($x); print $x;" 456
        >perl -le"sub f { $_[0]=3; } $#a=2; f($#a); print $#a;" 3

        it seems that those in the know are trying to fix it appropriately (or have already done so).

        I wrote a fix. It was reviewed by Rafael who fixed a big in it and committed it.

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://803981]
[james28909]: how can i write a while loop on one line (in a script) something like print "this\n" && print "that" && <DATA> && print the other\n" && next if /this matches/ while <DATA>?
[james28909]: i have tried with && and and and have tried to rearrange the functions as well to no avail
[shmem]: use parens to group expressions
[shmem]: you can't use next in a statement modifier
[shmem]: next requires a BLOCK

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (6)
As of 2018-05-20 18:44 GMT
Find Nodes?
    Voting Booth?