> X-Original-To: [EMAIL PROTECTED] > Mailing-List: contact [EMAIL PROTECTED]; run by ezmlm > From: Garrett Goebel <[EMAIL PROTECTED]> > Date: Thu, 30 Jan 2003 12:13:22 -0600 > X-SMTPD: qpsmtpd/0.20, http://develooper.com/code/qpsmtpd/ > > ------_=_NextPart_001_01C2C88B.468ED3D0 > Content-Type: text/plain; > charset="iso-8859-1" > > Apologies in advance for beating this dead horse... > > Damian Conway wrote: > > Garrett Goebel wrote: > > > > > What was the reason again which Larry rejected unifying the > > > syntax for array > > > and hash indexing? > > > > Because some things have both, and do different things with each. > > Ok $0 is special. But isn't it _the_ special case? And strictly speaking, > its an ordered associative array right? It doesn't really need the full > range of expression offered by $0{...} and $0[...]. All it needs is $0[1] > for ordered lookups and $0["1"] for named lookups. > > Or going back to the statement that "some things have both". Silly question > I'm sure, but can you imagine a collection object that really needs $0[1] > and $0{1}? And wouldn't it be a fair argument that such a collection object > is too fancy for its own good? > > Hmm... $0[$!] > > However isn't that something the collection object should have to deal with? > It seems like such nice thing to unify collection syntax. Then in Perl6 we'd > have scalars and containers. We'd still give sigils to arrays and hashes as > befits their perl heritage. Other collection objects could either be derived > from arrays and hashes, use some other generic sigil or define their own.
Alright, it's my turn. There is no I<real> reason why we can't unify hash and array indexing. It introduces some unavoidable caveats, sure, but on the ground level, there's no real *problem* with it. We've seen PHP and ECMAScript do it, so why can't we? Because the designers of PHP and ECMAScript didn't have quite the insight Larry did when he wrote Perl, in this respect at least. One of my favorite quotes that came up here just a little while ago was "we're not writing a turing machine...". Why, in English, do we say: The thing I<that> I tripped over upset me. but, The person I<who> tripped me upset me. It's perfectly clear what is meant if you use "that" in the second case, but the "who" just makes sure you got it. Perhaps you mis-heard/-read "person"; the "who" makes you rethink it and understand better. Perl is more a natural language than any other programming language to my knowledge. That's why its one of the only languages in which it's fun to write. The [] / {} distinction is just a redundant clarifier that would not be such a good idea to drop. Those unconvinced, read on. Consider this bit of code that you wrote 8 months ago (hypothetically): for blah blah $n this is too long to comprehend { print $users{$n}; } Another case of redundancy in your favor. Through the second line, you understand several things that [] would never tell you if they've been unified: * $users is a hash (or similar data structure) * $n is probably looping through names, not numbers. It's about comprehensibility, and this sort of "unnecessary" redundancy really helps us humans out when we don't have a perfect Perl 6 parser working for our brains. Which we never do. Luke