Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I was clapping until I stopped to wonder what a list is. Now I'm confused.

I can't find a definition of what a list is. The term is much used but the lack of definition is troubling. More so when considering phrases including "list" such as "list value" and "list context". Much can be inferred from what is said in the documents, but that isn't the same as having an authoritative definition. Am I missing one somewhere? I expected one in perlsyn and found none. I found most in perldata but still not a clear definition.

It appears, from various statements about or refering to lists in perldata that there is no syntactic construct that is necessarily a "list", even the syntax is dependent on the context, otherwise why brain twisters like:

In a context not requiring a list value, the value of what appears to be a list literal is simply the value of the final element, as with the C comma operator.

And I note in passing that this suggests not only that what looks like a list may not be, depending on the context, but also that what looks like the comma operator in something that would be a list in a context that required a list value but isn't because the context doesn't require it is not the comma operator but merely something that causes evaluation "as with" it.

So, now I know what I thought a list was and, for the sake of simplicity and sanity, what I wish it reliably and consistently was (i.e. a syntactic construct that is a syntactic list regardless of context with semantics that depends on context - what most recognize as "looks like a list"), but I don't know what a list is in Perl and seem to know less the more I read and think about it.

Maybe it is true that lists only exist in contexts requiring list values. If this is true, what is that thing that looks like a list but isn't because of the context?

Acceptance of the phrase "looks like a list" suggests there is a commonly understood underlying concept of list that Perl deviates from. It is unfortunate that there is a deviation from this commonly understood concept. It is worse that the deviant concept is so inimical to definition that no positive description is offered nor even a label other than the phrase "what appears to be a list". This deviant concept is, I think, at the root of the controversy, and as long as there is no definition of it the controversy will remain.

But I have enjoyed reading all the opinions and examples, and learned to be more careful in my thinking, so thanks all...


In reply to Re: If you believe in Lists in Scalar Context, Clap your Hands by ig
in thread If you believe in Lists in Scalar Context, Clap your Hands by gone2015

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



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (7)
As of 2024-04-25 11:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found