>
>$a is a hash key
>$b is an array index
>$c is another hash key
>
>So, if I try:
>
>@multi_dim[$b][$a][$c]
>
>then it's obviously going to break. But how can I, the
>programmer, easily spot that? It's not as clear as:
>
>@multi_dim{$a}[$b]{$c}
>
>where I can see what I'm getting as I work through the
>data structure.
>
A glance at my email tells me that several messages about this are yet to come, but
I'll risk repeating someone else.
What, exactly is the issue here? If $a is a hash key, that is clear by the funny
character.
%hash[key][additional][levels][of][depth]
If we are worried about about accidentally giving a key where an index is expected, I
don't understand how the semantics are much more confusing that the current ones. A
string'll get converted to a number and get used creating silent errors, or raise a
warning, which is not made more clear by the precence of a brace. If we're talking
about while I'm coding then the level of indirection by making the thing a variable in
the first place defeats any advantage that having the braces might give. For a really
BIG structure, if your are going to forget where the hashes are, then the braces
aren't going to help - you'll just put 'em inthe wrong place.
Printing out the value should solve the problem regardless - the braces don't seem to
make this issue much more clear. (To me anyway. I get the nagging feeling I'm missing
something.)
As to the inspring issue about using [] for hashes, I say go for it if (and only if)
it is a signifigant improvement for the parser. The historical pressure here is high,
so it can't just be a little faster.
However, if this isn't the 'idiomatic' sematics, I can see Perl in non-strict form
silently using whatever is between the []'s regardless of what the reference is. I
wonder at a)what sort of speed penalty we may be looking at for this, b)what degree of
advantage it is for QnD scripts and c)whether or not things like refs should really be
given that lazy a usage. Like modules perhaps, unstrictness in refs might be
unjustifiable.
-Erik
Is your boss reading your email? ....Probably
Keep your messages private by using Lycos Mail.
Sign up today at http://mail.lycos.com