Brent 'Dax' Royal-Gordon skribis 2004-04-15 16:56 (-0700):
> 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.
Curlies which, as said, I also don't like typing.
On a US Dvorak or QWERTY keyboard,
{'foo'} is 9 key presses and 7 characters
<<foo>> is 9 key presses and 7 characters
<foo> is 7 key presses and 5 characters
`foo is 4 key presses and 4 characters
Also important when picking a character is its glyph. ` is light weight,
like the . that we use for methods. I don't want whitespace around this
operator, so the operator must not be fat, like %, @ or #.
The biggest deficiency with the two syntaxes that are already there is
that they both use a pair of characters. That is needed because for some
reason every syntax apparently needs to support every feature that Perl
has. That is: slices.
I do not use hash slices often enough to use the arcane syntax all the
time. I like bracketing delimiters for code blocks and for lists of
things. They are not something I wish to type every line.
I dislike XML and HTML because they're a lot of typing (not only because
of the redundancy in the closing tags).
Perl 6's leaving out the parens with if/foreach/while/until is a very
good step in the right direction.
Compare:
$foo<bar><baz><quux>
$foo`bar`baz`quux
In fact, I encourage everyone to type the above two lines a few times.
> 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.
Same problem, and it would mean reversing an earlier decision that in my
opinion was a sane one.
It would require some character to disambiguate again, or you have the
unquoted strings that Perl 5 has, but restricted to hash usage. Adding a
sub or method that happens to have the same name as a hash's key should
not break any code.
> 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>.)
{:foo} is 8 key presses. A too small step to be worth anything in
practice.
> 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}.
Same as 3, but with another character.
Juerd