in reply to Re: Do you really want to use an array there?
in thread Do you really want to use an array there?
There's nothing in principle forcing a vector to have elements all of the same size, you just have to be a bit careful with the indexing if they are not.
What I do occasionally find frustrating is the lack of certain useful primitives when dealing with vectors, particularly vectors of booleans, since the resulting code can often become somewhat ugly and non-intuitive. Consider for example testing whether all(a_i & b_i) == 0:
# in an integer unless ($a & $b) { ... } # in a vector unless (($a & $b) =~ /[^\0]/) { ... }
I look forward to the promise of perl6 - where you could have a vector class, for example, "just like a string" except that it has a different concept of which strings are true. I think such a class would be difficult to achieve cleanly in perl5 without going down the path of tying/overloading, and losing most of the efficiency gains that caused you to turn to vectors in the first place.
Hugo
|
|---|