Brent 'Dax' Royal-Gordon skribis 2004-04-16 0:25 (-0700):I don't like %hash{'foo'} because it's ugly. I don't like %hash<<foo>> because it's ugly and adds syntax. I don't like %hash`foo because it's ugly, adds syntax, and looks nothing like an indexing operator. (I'll revisit this third point soon.) I think it will be easier to fix %hash{'foo'} or %hash<<foo>> than %hash`foo.
I have no doubt that between fixing existing things to make them nice enough to use very, very often and just implementing %hash`foo, the latter is by far the easiest to do.
But it isn't the *right* thing to do.
It's also worth noting that, except for Javascript, every language I can think of uses paired characters for indexing. Perl 5 uses {} and []; the C-like languages I know use []; Visual Basic (ugh) uses ().
Template toolkit uses a . for methods, indexes and keys. It's great for indexes. It's not so great for keys when there is a key that has the same name as one of the virtual methods.
Template Toolkit is a templating toolkit, not a language. It's meant for use in more limited places than Perl in general.
(And don't let this devolve into a flamefest about TT.)
Also, other languages are irrelevant, except for inspiration.>
Perl 6 mustn't be a copy of existing languages. It must be BETTER.
I thought that to make Perl a better language than all the other languages, we were supposed to be open minded about new ideas. But instead, many of the perl6-language subscribers keep referring to existing non-Perl-6 languages.
"Better" doesn't necessarily mean "different". I'm sure there are symbols for addition that are objectively "better" than +. I'm sure there's a name that's objectively "better" for 'wait'. These things stay the way they are because they're conventions.
Similarly, circumfix indexers are a convention in computer science. There are very few places where it *doesn't* hold true.
Your two examples are: 1. A templating system. 2. A scripting language that uses it as a clever way to get an OO system.
I do not see "a general-purpose programming language that added it in just for the hell of it" in the above list.
I dislike XML and HTML because they're a lot of typing (not only because of the redundancy in the closing tags).
I'd be inclined to agree with you. But we're talking about *one* *extra* *character* here. That's two keys. It's hardly the end of the world.
One extra character, two keys. EACH time. Still indeed not really a very big problem. However, bracketing operators are very heavy, visually. Unconsciously, you're matching them, counting them, seeing them.
The case we're talking about is a (probably) short, one-word key. I may be unconsciously matching and counting them, but it's not a difficult task.
(Although I wouldn't mind seeing <<>> go.)
Amen to that, at least.
"If the inside of a hash indexer consists entirely of \w characters, it will be interpreted as the name of a hash key. If you want it to call a subroutine instead, add a ~ stringifying operator to the beginning of the call, or a pair of parentheses to the end of it." Simple, clear, and doesn't shift around based on subroutine definitions. (It's not what Perl 5 does, but that's Perl 5's fault.)
That looks to me like exactly what Perl 5 does, except you use ~ instead of +.
The difference is that the rule is more limited--it only applies inside a hash indexer. Barewords are not a bad idea if they're carefully limited and defined.
It looks better to me and doesn't add any syntax.
It adds one hell of an ugly special case for the :pair syntax.
Better to add semantics than to add syntax.
To make my position clear: WE DO NOT NEED THREE WAYS TO INDEX A HASH.
We don't even NEED two! We don't need convenient aliasses in regexes. We don't need threads. We don't need lexical variables. We don't need junctions. We don't need any dwimmery.
But please, let's write Perl 6 instead of another Java-wannabe.
We don't NEED anything except zeroes and ones.
But all these nice features are damn nice to have!
Regex aliases, threads, lexicals, junctions, and dwimmery make things a *lot* easier to program. This syntactic sugar you're proposing doesn't. It saves you a few keystrokes at the cost of complicating the language.
I don't really think we need two. All we really need is one way with a good enough syntax to meet all of our needs.
Or three syntaxes of which you can choose, depending on what you mean and like to write.
I thought Perl minded people were used to TIMTOWTDI, but I'm proven wrong once again.
"TMTOWTDI" means "don't let redundancy stop you from adding a good feature". It doesn't mean "accept every feature that's proposed, no matter its merits".
-- Brent "Dax" Royal-Gordon <[EMAIL PROTECTED]> Perl and Parrot hacker
Oceania has always been at war with Eastasia.