I do not believe perl literally puts all 1,000 elements of longarray on the stack and then pops it, as C would do.

Read the source code; the relevant function is pp_aassign in pp_hot.c.

when I tried it, call(@longarray) and call(\@longarray) took almost the same amount of time.

That doesn't mean anything; wallclock is the second worst way to benchmark anything. It's too fragile and you can't trust it.

I do not understand what the purpose of a list is.

A list is a sequence of zero or more expressions. Without a list... well, you'd have no program.

if sub's returned arrays, then they could easily be assigned back to arrays

If Perl 5 subs returned arrays, not lists, you'd need special syntax (like function return slicing) to do anything else than assign to arrays. You'd also have to figure out how to return a list of arrays; you'd have to add some sort of literal tuple as a first-class data structure, and then you get into the complexity of fixed arity versus variable arity, and ... well, Perl 5 has its flaws, but I'm not sure you gain a lot making this more complex here.


In reply to Re^4: Speed of Array Returns by chromatic
in thread Speed of Array Returns by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.