doesn't it hold that when the multiple scalars produced by slicing an array is pushed onto the stack, it also becomes a list? And that all but the last element of that stack-held list of scalars are then discarded when in a scalar context?

So whether an op returns a list or not depends on whether it creates a list internally? It doesn't makes sense to describe the result of a function using different terminology based on whether it builds a list internally or not in order to return that result.

For example, say grep built a list on the stack even in scalar context in an old version of Perl. According to what you said, that grep returns a list in scalar context. That means grep returns a list in scalar context in one version of Perl but not in others, despite returning the number of unfiltered elements in both.

Is it such a "bad meme" to say: A slice results in a list. And a list in a scalar context will return the last element of the slice?

Yes, cause it commonly fails. In the aforementioned version of grep, grep results in a list. And a list in scalar context will return... the last element of the grep? No, it didn't.


In reply to Re^8: Scalar context of slice ("list") by ikegami
in thread Scalar context of slice by thenaz

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.