Why use Perl when we've got Python?!
Sam Holden
sholden at pgrad.cs.usyd.edu.au
Fri Aug 13 23:36:23 EDT 1999
On Sat, 14 Aug 1999 03:08:33 GMT,
John Stevens <jstevens at bamboo.verinet.com> wrote:
>On 14 Aug 1999 02:32:12 GMT, Sam Holden <sholden at pgrad.cs.usyd.edu.au> wrote:
>>On 13 Aug 1999 20:04:03 -0700,
John W. Stevens <jstevens at basho.fc.hp.com> wrote:
>>>
>>>Perl doesn't have lists. Python doesn't have built-in arrays.
>>
>>You should learn some perl you now..
>>
>>@array = (1,10,20,30);
>>$from_list = (1,10,20,30);
>>$from_array = @array;
>>print "$from_list\n$from_array\n";
>>
>>Will output :
>>30
>>4
>
>The @ prefix denotes an array. You, yourself, should learn
>Perl. Calling an array a list, doesn't make it one.
Can you read?
Can you see a @ in the following line of code :
$from_list = (1,10,20,30);
No you can't. Is there an array in that line of code? No. Is there a list
in that line of code? Yes. Do lists and arrays behave differently? Yes, just
look at the different outputs.
>
>>Perl has lists,
>
>Not built in, it doesn't, unless you define array and list as being
>different words for exactly the same type/class.
I don't think you can get more built in then perl lists.
Again I repeat, here is a perl list : ('a', 'b', 'c') or qw(a b c)
>
>>if you know perl you would know this.
>
>I know Perl. You need to learn Python.
Did I mention a single bit of python syntax in my post? No.
Was I discussing python syntax? No.
Do you know if I use python? No.
Do you know if I like python? No.
Do you know if I have already spent time learning python?
Do you know if I am currently learning python?
What was the point of saying I need to learn Python? I wasn't saying python
was worse than perl, I wasn't saying python syntax is strange, I wasn't
talking about python. You might as well have told me to learn C or Lisp.
At least Lisp would be more relevant than python, if you were trying to
tell me to learn about lists in some strange abstract way.
Have I questioned your python knowledge? No.
Have I questioned your perl knowledeg? Yes, but only because you have
consistantly made basic mistakes when speaking about perl.
>
>>If you program in perl
>>and don't know this, then you must get very very confused at times.
>
>If @ denotes list, then the following Perl would be illegal:
>
>@ary = (1, 2, 3);
>@ary[5] = "Test";
>
>But, obviously, this is not illegal.
@ary[5] is an array slice. It is an array. It happens to be an array
that constists of only one element. Why would it be illegal? It is just
the special case of :
@ary[1,2,3,4,5,10,20]
It is an array. Thus it has a @.
Used like that it is almost a sure indication of an error by the programmer,
because a single element array slice has no benefit over the simple
array element in that context.
>
>>>I will assume that a list module is available for Perl.
>>
>>No it is one of the built in bits... like hashes and arrays.
>
>Really? What is the prefix character that denotes a list?
You can't have a list in a variable. Lists in perl are constant. So
what would be the use of putting them in a _variable_. Just because there
is no list variable does not mean there are no lists. Again here is a list :
(1,2,3,4,5,6,7,8)
>
>>>I wasn't trying to compare features, I was simply pointing out
>>>that your comparison was Apples and Oranges, and therefore at
>>>least somewhat invalid.
>>
>>Only because you have no idea what you are talking about.
>
>:-)
>
>Coming from somebody who doesn't know the difference from *EMULATING*
>a list with an array, vs. a real array, that is a good one!
Again here is a list :
(1,2,3,4,5,6,7,8)
That is not an array. It is a list. It is different from an array. I already
showed how assigning to a scalar gives different results for lists and arrays,
here are some more differences :
push( (1,2,3,4,5), 6);
This results in an error message, funnily enough the message is :
Type of arg 1 to push must be an array (not list)
Still claim perl has no lists? Of course you know better then perl itself.
@array = (1,2,3,4,5);
push(@array,6);
That works fine, because we are passing an array to push not a list.
Pop is the same :
pop (1,2,3,4,5);
Is an error (the message is as above s/push/pop/)
@array = (1,2,3,4,5);
pop @array;
Is legal and pops the 5 off @array.
>
>Now I suppose that you will tell me that Perl has stacks, too!
>;->
No it doesn't.
--
Sam
why can't newbies use hash slices in their hello world programs? :-)
-- Uri Guttman in <x74skxhve5.fsf at home.sysarch.com>
More information about the Python-list
mailing list