On Fri, Apr 16, 2004 at 10:44:47AM -0700, Brent 'Dax' Royal-Gordon wrote:
Regex aliases, threads, lexicals, junctions, and dwimmery make things a *lot* easier to program. This syntactic sugar you're proposing doesn't.
But it *does* make an oft-used construct easier to type. That adds up over time and as the amount of code increases. Or do you dispute that $hash{'key'} is oft-used or that %hash{'key'} will be oft-used?
I don't claim that they won't be used often. I claim that the *best* solution is to fix the syntax we already have, not add more. Failing that, we should make sure that the syntax we add is as globally useful as possible. The form of backticks you're proposing are good for only one thing: indexing hashes (and possibly arrays). Clever definition of the colon operator, or creation of a bareword-quoting operator, would allow you to use "barewords" anywhere you wanted to.
It saves you a few keystrokes at the cost of complicating the language.
The amount it complicates the language seems infinitesimally small to me (compare it to all of the added complexity in perl6 so far). Disambiguation based on context works. Show me the complications you see.
The complications I see are in things like:
To get an item out of a hash, you can write %varname{"key"}. You can also write %varname<<key>> if there aren't any spaces in the key. Finally, if the key doesn't have any characters in it except for letters, numbers and underscores, you can write %varname`key.
Compare that to (assuming barewords are allowed in hash indexers):
To get an item out of a hash, you can write %varname{"key"}. If the key doesn't have any characters in it except for letters, numbers, and underscores, you can write %varname{key}.
Or, with the colon proposal:
To get an item out of a hash, you can write %varname{"key"}. If the key doesn't have any characters in it except for letters, numbers, and underscores, you can write %varname{:key}.
Which explanation is shorter? Which is more logical? Which has the fewest special cases?
I'm going to throw in one more argument at this point. It's based on a game you all played as children: Which One Of These Doesn't Belong?
&stuff(1) @stuff[1] %stuff{1} %stuff«1» %stuff`1
-- Brent "Dax" Royal-Gordon <[EMAIL PROTECTED]> Perl and Parrot hacker
Oceania has always been at war with Eastasia.