go ahead... be a heretic | |
PerlMonks |
(tye)Re2: tr doesn't *really* use a listby tye (Sage) |
on Dec 28, 2000 at 00:05 UTC ( [id://48518]=note: print w/replies, xml ) | Need Help?? |
I would say that a list in Perl is any grouping of scalars (including groupings of zero or one scalar) on the stack. Then ($a,$b,$c) isn't a list. It might produce a "list" (using your definition), if used in a list context. I certainly consider ($a,$b,$c) a list. It is a list of scalar expressions which has everything to do with the syntax of the construct and nothing to do with some Perl data structure which certainly exists (in multiple forms) but that people keep wanting to say is the one true meaning of "list" when dealing with Perl. "List" can mean a list of scalars in memory, much like a Perl array, but it can also mean many other things. I find people repeatedly getting into trouble due to attempts to nail down the definition of a "Perl list". There is no one definition of a "Perl list". Update: and the reason this leads to trouble is that even if we restrict ourselves to the standard documentation that comes with Perl, the word "list" is used to mean many different things in that documentation. Sometimes the word "list" is used to mean different things by the same author in the same paragraph. So if you have a "nailed down" meaning for "list", some part of the Perl documentation will tell you wrong things (like that tr takes a list of scalars). Note that I don't think we should "fix" this by only using "list" to mean only one thing in the Perl documentation. I'd hate to see the ton of "Oops, I wrote 'list' but that wasn't a Perl List(tm) I was talking about so I'll have to call that a... uh.. 'set'... no, hmm... 'collection', uh, 'tuple'. Yes 'tuple'!" - tye (but my friends call me "Tye")
In Section
Seekers of Perl Wisdom
|
|