Juerd wrote:
I think %hash`key makes sense. But I'd like to find out if more people
like this idea.

We already have two hash dereference syntaxes. That's arguably one too many as it is. Let's fix the deficiencies in the syntax we have, rather than adding even more syntax with even more deficiencies.

Oh, you want a specific proposal? Pick one of four:

1. Allow %hash<<foo>> to be typed as %hash<foo>.  There would be a
   conflict with numeric less-than, but we can disambiguate with
   whitespace if necessary.  After all, we took the same solution with
   curlies.

2. Allow barewords in curlies as a special case.  We're already allowing
   them on the left side of => (I think), which is even more ambiguous.

3. Define hash indexing with a pair to index on the key.  This would
   allow the syntax %hash{:foo}.  (This could even be achieved by making
   C<~$pair eq $pair.key>.)

4. Define a bareword-quoting prefix operator (i.e. one that turns the
   next \w+ into a string) and use the normal hash indexer, {}.  I have
   no suggestion for this operator's name, although if you wanted to rip
   out the current unary backticks, it could be a candidate:
   %hash{`key}.

In the last three proposals, I would remove the <<>> indexer.  I feel
that indexing with a slice of \w keys is not a common enough operation
to warrant the extra indexer, even with the parallel to the <<>> list
constructor.  However, it's worth noting that #3 gives you a fairly
convenient construct to do just that (%hash{:foo :bar}), and #4 could
probably be defined to do the same.

(For the record, I have nothing against the <<>> list constructor.  That
was a stroke of genius.  I just don't like having a separate indexer
based on it.)

As for removing the term ``, I see no compelling argument to do so.
Perl has never been, and should never be, the sort of nanny language
that makes fundamental operations less accessible just because they're
security risks.  Heck, we gave our users the 'x' operator, arguably the
easiest way in any language to fill up memory quickly.

--
Brent "Dax" Royal-Gordon <[EMAIL PROTECTED]>
Perl and Parrot hacker

Oceania has always been at war with Eastasia.




Reply via email to