It makes sense to me!

In Perl, 'it' is spelled '$_', and is an important part of the design of Perl 5, growing more important in Perl 6, and in the Perl 6 pieces that were back-ported into perl 5.10. Remember, Larry Wall is a linguist by training, and understands the value of pronouns. From Perl 6 and Parrot Essentials:

$_ is always the current topic (think "topic of conversation"), so the process of aliasing a variable to $_ is known as topicalization.

Consider this expression:

$entirely{TOO}[$long]{$var} = 42 if $entirely{TOO}[$long]{$var} < 5;
In Perl 5, the idiom for briefly topicalizing a variable is the single-item for statement:
for ( $entirely{TOO}[$long]{$var} ) { $_ = 42 if $_ < 5; }
This is slightly jarring at first; we expect a for loop to, well, loop! I had to use the idiom a few times to get used to it.

If you need multiple (yet discrete and update-able) pronouns at the same time, the Data::Alias module can create them. ($his and $hers?)

Unfortunately, none of this can help with your specific example. The delete function, like exists, does not actually operate on a hash value; it is more of a method call on the hash "object" with the key as a parameter. In fact, I believe that in Perl 6, delete %myhash{$mykey} is really just syntactic sugar for %myhash.delete($mykey).

You can look at it this way: nearly everything you do with %myhash{$mykey} involves retrieving the value stored in the $mykey bucket, doing something with it, and possibly storing it back in its bucket. The major exceptions are delete and exists, which deal with destroying or verifying the bucket *itself*. The fact that we use the same %myhash{$mykey} syntax for everything is just for convenience; the cases are quite different under the hood. An alias that allows deletion of the alias-forming-key may be too much to expect, but I agree that it would be convenient.


In reply to Re: Pronoun Programming by Util
in thread Pronoun Programming by rje

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.