Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re: If you believe in Lists in Scalar Context, Clap your Hands

by ig (Vicar)
on Oct 26, 2008 at 22:28 UTC ( #719674=note: print w/ replies, xml ) Need Help??


in reply to If you believe in Lists in Scalar Context, Clap your Hands

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...


Comment on Re: If you believe in Lists in Scalar Context, Clap your Hands

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://719674]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others taking refuge in the Monastery: (9)
As of 2014-09-22 18:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    How do you remember the number of days in each month?











    Results (198 votes), past polls