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

Unfortunately, none of those 'remedies' work:

C:\test>p1 [0] Perl> use Devel::Size qw[ size total_size ];; [0] Perl> @a = 1 .. 10;; [0] Perl> print size( \@a ), ':', total_size( \@a );; 256 : 496 [0] Perl> print $#a;; 9 [0] Perl> print size( \@a ), ':', total_size( \@a );; 440 : 680 C:\test>p1 [0] Perl> use Devel::Size qw[ size total_size ];; [0] Perl> @a = 1 .. 10;; [0] Perl> print size( \@a ), ':', total_size( \@a );; 256 : 496 [0] Perl> $x = 0+$#a;; [0] Perl> print size( \@a ), ':', total_size( \@a );; 432 : 672 C:\test>p1 [0] Perl> use Devel::Size qw[ size total_size ];; [0] Perl> @a = 1 .. 10;; [0] Perl> print size( \@a ), ':', total_size( \@a );; 256 : 496 [0] Perl> $x = ${ \$#a };; [0] Perl> print size( \@a ), ':', total_size( \@a );; 432 : 672

In every case, the mere mention of $#a has already caused the damage to be done. Trading 76-bytes per array to save 4-bytes per array does not make sense.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP PCW It is as I've been saying!(Audio until 20090817)

Replies are listed 'Best First'.
Re^11: Does @{ } copy arrays?
by ikegami (Patriarch) on Oct 23, 2009 at 22:56 UTC

    In every case, the mere mention of $#a has already caused the damage to be done.

    As I've already mentioned, we're talking about a Perl that's fixed to not add the magic for rvalue $#a.