in reply to Re: Dotted hash access
in thread Dotted hash access
Isn't this problem supposed to be corrected in Perl6?
For several reasons, the dot cannot be used safely for hash access. I proposed backticks for this purpose, but it's not going to happen, because many find it too ugly (since when is that reason to not do something in Perl?), and the powers that be have decided. See also http://groups.google.com/groups?selm=20040414121848.GJ3645%40c4.convolution.nl;
Still, I think it elegantly solves the problem.
would be written as$cost = $h->{Locations}{$location}{Buildings}{$b}{cost};
$cost = $h`Locations`$location`Buildings`$b`cost;
I want this for two reasons:
will be$cost = $h->{Locations}{$location}{Buildings}{$b}{cost};
or$cost = $h{'Locations'}{$location}{'Buildings'}{$b}{'cost'};
in Perl 6.$cost = $h«Locations»{$location}«Buildings»{$b}«cost»;
IMO, the OP has a good point. Hash access is nice, and the syntax is certainly doable, but it gets tedious for accessing an deep element in a HoHoHoH. And even though many things are made much easier by Perl 6, this specific thing is IMHO made much worse.
(Please, let's not start another "write your own grammar" subthread.)
Juerd # { site => 'juerd.nl', plp_site => 'plp.juerd.nl', do_not_use => 'spamtrap' }
|
|---|