Why use Perl when we've got Python?!

Sam Holden sholden at pgrad.cs.usyd.edu.au
Sat Aug 14 23:09:30 EDT 1999


On Sat, 14 Aug 1999 14:57:21 GMT,
    John Stevens <jstevens at bamboo.verinet.com> wrote:
>On 14 Aug 1999 03:36:23 GMT, Sam Holden <sholden at pgrad.cs.usyd.edu.au> wrote:

>Your example included:
>
>@array = (1,10,20,30);
>$from_list = (1,10,20,30);
>$from_array = @array;
>print "$from_list\n$from_array\n";
>
>The line you specify does not contain a list, it contains a
>tuple.
>
>>No you can't.  Is there an array in that line of code?
>
>No, and that isn't a list, even if you call it one.  It is a tuple.
>
>>No. Is there a list
>>in that line of code?
>
>No, it's a tuple, not a list.

You can play semantic games all you like, here's the only definition of
a tuple that I could find :

tuple :
In functional languages, a data object containing two or more
components. Also known as a product type or pair, triple, quad, etc.
Tuples of different sizes have different types, in contrast to lists
where the type is independent of the length. The components of a tuple
may be of different types whereas all elements of a list have the same
type. Examples of tuples in Haskell notation are (1,2), ("Tuple",True),
(w,(x,y),z). The degenerate tuple with zero components, written (), is
known as the unit type since it has only one possible value which is
also written ().

Sorry perl's lists are not tuples. Since they can only store values of
one type - scalars. You can't have a list of lists (sorry tuple of tuples),
only a list of scalar refernces to a lists (sorry tuple of scalar references
to tuples).

Perl uses the word list. The word list has many more meanings in the English
language than the Mathematics definition I'm sorry. Perl uses a different
meaning than you like, go and take it up with whoever publishes your
dictionary.

>Go ahead, show me a variable that contains a list.  In your
>example:

Did you read my post. Particularly the bit in which I said you can't have
a list in a a variable. Anyway I give up - learn how to read, and accept
that perl uses the work list differently than python.

>
>$from_list = (1,10,20,30);
>
>$from_list isn't a list.
>
>>Again I repeat, here is a perl list : ('a', 'b', 'c') or qw(a b c)
>
>Again, you are wrong.  The construct ('a', 'b', 'c') is a tuple.
>Perl'ers may call it a list, but how do you perform a an insert
>on the above?

Strangely enough perl didn't involve in an ivory tower. It isn't meant to
be a 'pure' language, it doesn't have lots of 'theory' behind it. Here's a good
definition of a list that the paper boy will tell you is a list :

list n 1: a database containing an ordered array of items (names or
topics) [syn: listing] 2: the property possessed by a line or surface
that departs from the vertical; "the tower had a pronounced tilt";
"the ship developed a list to starboard"; "he walked with a heavy
inclination to the right" [syn: tilt, inclination, lean, leaning] v
1: give or make a list of; name individually; give the names of 2:
include in a list 3: give the names of; "Name the states west of the
Mississippi!" [syn: name] 4: enumerate; "We must number the names of the
great mathematicians" [syn: number]

no mention of operations there. When I ask for a list of birthdays, I don't
want something I can insert into, or delete from. I want a bunch of dates
written on a peice of paper. Feel free to ask for a tuple of birthdays, I'll
stick you common English though thanks.

>
>You don't.  You copy the contents of your tuple into an array,
>then perform array operations on that array.
>
>>>I know Perl.  You need to learn Python.
>>
>>Did I mention a single bit of python syntax in my post? No. 
>
>So what?  I can still make a comment.  And if you had been
>paying attention, you would have realized the context of this
>thread.

And if you read my post you would have realised I avoided comparing perl
and python in any way.

>
>>What was the point of saying I need to learn Python?
>
>Because, in the words of TC, "Learning is a good thing".
>
>More specifically, had you studied Python, it would have been
>clear that what Perl calls a list is more properly refered to
>as a tuple.

I agree with you. An earlier post by TomC specifically said that. Perl
calls them lists, thus they are lists. If Perl called them Hamburgers then
they would be hamburgers. Of course that would make perl harder to talk
about and to understand from the documentation.

Show a bunch of people the following (try paper boys, programmers,
mathematicians, etc) :

1,2,3,4,5,6,7,8,9

Ask them what it is.

I bet more people say a 'list' than say a tuple.

Perl didn't come from an ivory tower, it uses English words for their 
English meanings a lot. You don't like that, fine, just don't argue perl
doesn't have lists when you know it does. 

If you had said "perl doesn't have lists, what it calls lists are really
tuples', I would have answered with aomething like the above. I misunderstood
and thought that you thought arrays and lists where exactly equivalent in perl.
That is a common mistake in perl, that people who make the mistakes that you
have made with perl code in this thread make. People who struggle with
using @ where they mean $ and {} where they mean (), etc tend to be
misunderstanding the basic data structures perl provides.

I made a mistake, I can admit that.

I do have a feeling that you knew I was and kept going anyway because you
like to argue about stupid pointless things.

>
>>You might as well have told me to learn C or Lisp.
>
>Yes.  You should.  Had you learned Lisp, list processing would
>be second nature to you, and you would have a clearer idea between
>"lists" and "tuples" and "arrays".

In fact I have. But the meaning of 'list' when talking about perl is whatever 
perl calls a list. Ignore it all you want. You must get misunderstood a lot.

>
>Stop.  You are talking about arrays, not lists.  I repeat, if
>@ary were a list, the above operation would be illegal.

But @ denotes an array and you know this. 

>
>>Of course you know better then perl itself.
>
>In this case, I would say that Perl should use the same terminology
>as other fields of study.  So, yes, I would consider that Perl
>makes a mistake, calling this a list.

That's fine, your allowed to disagree with the terminology. but since you
in all likelyhood knew what I meant anyway you have just been playing games.


*plonk*

-- 
Sam

I explicitly give people the freedom not to use Perl, just as God gives
people the freedom to go to the devil if they so choose.
	--Larry Wall




More information about the Python-list mailing list