in reply to Re^3: Perl vs C
in thread Perl vs C
Please explain what you think the difference is between a Perl array and a Perl List.Arrays are variables, lists are values. It's the same difference as between $foo and 3.
I think this just some kind of nomenclature difference.. Not any real disagreement!Differences in nomenclature are not something to trivialize - specially not when it's about important concepts.
A simple Perl list is similar to a C char ** array (array of pointers of pointers to strings)No, it's not. First of all, a char is not a string, but a (small) integer. Depending on usage, a C char is equivalent to a Perl integer, or a Perl string consisting of exactly one character. Secondly, in C, array elements all have the same size - all elements are integers, characters or pointers for instance. (Pointers in your example). In Perl, values of a list can have different "sizes" - or rather, different types (mixed integers, references, objects, strings, etc) - as the "size" of a value isn't a useful concept in Perl (it is in perl, but not in Perl). Third, and this is the big one, elements of an array may change (both in C and in Perl). But in Perl, lists are unmutable (of course they can be changed by perl, or by using XS - but not from a Perl POV). They are as unmutable as the value 3.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: Perl vs C
by Marshall (Canon) on Mar 16, 2009 at 13:54 UTC | |
by JavaFan (Canon) on Mar 16, 2009 at 14:07 UTC | |
by Marshall (Canon) on Mar 16, 2009 at 14:15 UTC | |
by JavaFan (Canon) on Mar 16, 2009 at 14:23 UTC | |
by Marshall (Canon) on Mar 16, 2009 at 15:00 UTC | |
|