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.

$cost = $h->{Locations}{$location}{Buildings}{$b}{cost};
would be written as
$cost = $h`Locations`$location`Buildings`$b`cost;

I want this for two reasons:

  1. Typing { and } repeatedly is hard, at least for my hands
  2. Typing {'key'} or «key» is even harder
Realise that
$cost = $h->{Locations}{$location}{Buildings}{$b}{cost};
will be
$cost = $h{'Locations'}{$location}{'Buildings'}{$b}{'cost'};
or
$cost = $h«Locations»{$location}«Buildings»{$b}«cost»;
in Perl 6.

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' }


In reply to Re^2: Dotted hash access by Juerd
in thread Dotted hash access by sfink

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.