[EMAIL PROTECTED] ("c. church") writes:
>----- Original Message -----
>From: <[EMAIL PROTECTED]>
>> I agree. C<$hash{foo}{bar}{baz}> is horribly ugly. Your solution
>> is a redesign. My solution is to use whitespace. The latter is
>> far easier than the former.
>Personally, I disagree - $hash{foo}{bar}{baz} is extrmely descriptive. I
>like it. I can look in once place and see exactly what I need.
>If that's bad, just use something nearly as bad once, i.e.:
>my $hRef = \%{ $hash{foo}{bar} };
>my $blah = $hRef->{baz};
Ummm, why not just
my $hRef = $hash{foo}{bar};
my $blah = $hRef->{baz};
? \%{ $x } just gives you back $x, if it is in fact a hash ref. If it
isn't, you've only moved the error by one line.
>Btw, I really like the infix operator. It's pretty, it fills my code with
>all sorts of warmness of knowing exactly what it means. =)
What I've sometimes wished for is some way of dereffing to a hash or
array using -> or some related postfix thing. So instead of
my $aref = $hash{foo};
for my $key ( keys %$aref ) { print $hash{bar}->{$key} }
or
for my $key ( keys %{ $hash{foo} } ) { print $hash{bar}->{$key} }
I would like to write
for my $key ( $hash{foo}->keys ) { print $hash{bar}->{$key} }
or even
for my $key ( keys $hash{foo}->% ) { print $hash{bar}->{$key} }
... I'd find these easier to make sense of, though I've got a sneaking
suspicion that I'm in a small minority there. But of course they'd be
fun, because I could inflict them on unsuspecting readers of my code.
Lars Mathiesen (U of Copenhagen CS Dep) <[EMAIL PROTECTED]> (Humour NOT marked)