That said, it seems blindingly obvious that return @this returns an array!

Is it blindly obvious--really? Would you also say that return &foo obviously returns a subroutine?

return @array doesn't return an array any more than return &foo returns a subroutine. The key is that return EXPR doesn't make the subroutine/eval/do FILE return the expression itself, but rather the evaluation of the expression, which may depend on the context in which the subroutine/eval/do FILE is evaluated.

But would we say that an array is a list or a scalar?

You're focusing on what an array is in different contexts. An array is an array. If you focus on what an array evaluates to you'll get more to the point. Every evaluation is in a context, and an array evaluates differently in list versus scalar context just as a subroutine (may) do. perldata says (my emphasis)

Note that the value of an actual array in scalar context is the length of the array
i.e., it evaluates to the length.

lodin


In reply to Re^5: Evil Interview Questions (memes) (return @foo VS return &foo) by lodin
in thread Evil Interview Questions by kyle

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.