Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

(tye)Re: Scalars, Lists, and Arrays

by tye (Cardinal)
on Apr 13, 2001 at 19:19 UTC ( #72359=note: print w/ replies, xml ) Need Help??


in reply to Re: Scalars, Lists, and Arrays
in thread Scalars, Lists, and Arrays

Excellent answer.

I find that trying to nail down "list" to mean something very specific like you have done just runs into problems down the road, though. For example, you say "(1,2,3) is not a list" but that contradicts parts of the Perl documentation. I understand what you mean in the context of this discussion but I think it is important for people to come away from the discussion and realize that many of the things that you say about "lists" above won't match things that a lot of other people (and documentation and books) are going to say about "lists" (because they are using a different definition of "list" than you).

See (tye)Re: @_0 vs. $_0, (tye)Re2: tr doesn't *really* use a list, (tye)Re3: tr doesn't *really* use a list, (tye)Re2: List context or not?, and (tye)Re3: List context or not? for my thoughts on "lists" in Perl.

        - tye (but my friends call me "Tye")


Comment on (tye)Re: Scalars, Lists, and Arrays
Re: (tye)Re: Scalars, Lists, and Arrays
by merlyn (Sage) on Apr 13, 2001 at 19:34 UTC
    The Perl documentation has two different things that both end up being casually called "list": "list values" and "list literals". A "list literal" is that comma-ish thing that turns into the comma operator in a scalar context (last value wins). A "list value" is the result from executing an operator in a list context. And yes, a list literal yields a list value in a list context, hence leading to the casual use of "list" for both.

    In an ideal world, all naked "list" mentions would be expanded to either "list value" or "list literal" as appropriate. But most people generally figure it out by context (gah!) anyway.

    -- Randal L. Schwartz, Perl hacker

      One of the other threads I mentioned (tr doesn't *really* use a list), as you can tell from the title, shows how "list" is used in the Perl documentation to talk about at least one more thing than the two that you list. This appears to have caused at least a little confusion.

      I'd list all of the ways that "list" is used within the Perl documentation, but the thought of compiling such a list makes me listless. ;)

      I think that being able to talk about a "list" within a given documentation context is helpful in making the documentation easy to read. So no, I don't think changing "list" to "list literal" or "list value" everywhere would be an improvement.

      There are some places in the documentation that could be made more clear by being explicit about what is meant by "list" in that section.

      But I think the important thing is to get people to realize that they have to figure out what is meant by "list" in each context. And that is what I am trying to do.

              - tye (but my friends call me "Tye")

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (2)
As of 2014-09-17 03:36 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

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











    Results (57 votes), past polls