Larry Wall wrote:
On Sat, May 14, 2005 at 12:51:32PM -0500, Rod Adams wrote:
: Unless, of course, there is some subtle difference between a 3-d hash : and a hash of hashes of hashes that invalidates this.
No difference, I hope. The multidimensional notation is meant
to extend to HoH and AoA transparently (as well as HoA and AoH).
Since a variable's dimensionality is always declared (and a container
object's dimensionality generated at "new" time), we shouldn't have
to worry about whether to add dimensions or autovivify a reference.
Either there's storage already allocated, or we autovivify.
Hmm. So if I say:
@a = [ { a => 1, b => 2}, { a => 3, b => 4 } ];
Can I then say:
$x = @a[1;'b'];
And get $x = 4?
And that gets me wondering what the real difference between .[] and .{} is. Best I can tell, it's only how they autovivify dimensions not yet existent. Which would make the following an error:
@a[2;'a'] = 5;
Since it would attempt to autovivify @a[2] as an array, and 'a' is an invalid array subscript (unless you do some voodoo to arrays). However,
@a{2;'a'} = 5;
Should work fine, since the first dim already has storage as an array, and the second gets autovivified as a hash.
All of this changes if you explicitly declared the shape of @a somewhere.
Of course, it's entirely possible I've completely misconstrued your above statement.
-- Rod Adams