Garrett Goebel wrote:

Ok $0 is special. But isn't it _the_ special case?
Nope. Pretty much any built-in that returns more than a single
piece of information (e.g. C<caller>, C<want>, C<stat>, etc.)
will do the same kind of thing.

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.
Nope. The array aspect returns $1, $2, $3, etc.
The hash aspect returns the named captures.


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}?
Sure. Imagine an object that stores frequency counts for input strings. It's very likely that the frequency count for the second most common string (i.e. $freq[1]) isn't the same thing as the frequency count for the string "1" (i.e. $freq{1}).


And wouldn't it be a fair argument that such a collection object is too fancy for its own good?
Not to me, no. Nor to Larry apparently, since he deliberately set up the
$0, $1, $2, etc. variables that way.


Hmm... $0[$!]
Indeed.


It seems like such nice thing to unify collection syntax.
Not to me.

See http://www.csse.monash.edu.au/~damian/papers/PDF/SevenDeadlySins.pdf
Specifically, the sections entitled "Grammatical traps" and
"Differentiate semantics with syntax".


People, the whole argument that $a[key] should be a homonym for both
array-like and hash-like look-ups is the same argument that it's
good to have two C<select> functions, two C<eval>s, two C<for>s,
two C<goto>s, or three C<do>s. That has proved *not* to be a great
thing in perl 5 and Perl 6 is clearly moving away from it.

Let's move on too.


Damian

Reply via email to