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

Well, wouldn't $#{}, and @{} in a scalar context need similar magic? Isn't the second just an increment of the first? (There must be more magic anticipated by $#{} to warrant the slowdown?)

-QM
--
Quantum Mechanics: The dreams stuff is made of

Replies are listed 'Best First'.
Re^4: Does @{ } copy arrays?
by dave_the_m (Monsignor) on Oct 17, 2009 at 10:57 UTC
    @a in scalar context just pushes its size onto the stack. $#a in scalar context could be an lvalue or an rvalue, so a 'magic' var is pushed onto the stack that updates the array's size if assigned to. This could probably be optimised when pp_av2arylen is called in rvalue context.

    Dave.

      Ah, of course. I suppose there are cases where it's not immediately apparent to the parser if a given occurrence is an lvalue or rvalue?

      -QM
      --
      Quantum Mechanics: The dreams stuff is made of

      This could probably be optimised when pp_av2arylen is called in rvalue context.

      Done by commits 02d85cc37a4acecafdc2f0b45640b03cd1f4ac71 and 28c5b5bcd7f52e6b2219508a1066cd0ccc8dd19a. You'll see these changes in 5.11.2 (next month's dev release) and 5.12 (early to mid 2010)