[pm-h] Interesting Blog Posts on Context & Array vs List

Uri Guttman uri at stemsystems.com
Wed Feb 19 21:25:22 PST 2014


On 02/19/2014 11:04 AM, Robert Stone wrote:

>
> Linked in that article is also another interesting posting on the differences between Arrays and Lists.
> http://friedo.com/blog/2013/07/arrays-vs-lists-in-perl
>

in reading that list of differences, i see some issues. arrays aren't 
variables but containers. anon arrays aren't variables either. arrays 
can be referred to by a variable.

and variable (really container) isn't the opposite of ephemeral.

in perl arrays are always one dimensional. that comment is somewhat off.

the point about lists distributing references is true but extremely 
obscure. i can't recall having ever seen code that does \($x, $y, $z) 
and want \$x, \$y, \$z. just a bizarre little corner case that no one 
should need or want to use.

the part about passing arrays to subs is somewhat wrong. what about a 
prototype that takes an array? true, perl passes its reference to the 
sub in @_ but the calling call shows an array being passed in.

what i tell perl students is that:

arrays are allocated from the heap. lists live in the stack.
arrays can live between statements. lists only live in an expression

that is usually enough to clarify the differences. it is all about where 
the data is stored and how long can it live.

thanx,

uri


-- 
Uri Guttman - The Perl Hunter
The Best Perl Jobs, The Best Perl Hackers
http://PerlHunter.com


More information about the Houston mailing list