At 9:22 AM -0700 7/14/06, Dave Whipp wrote:
Darren Duncan wrote:
Assuming that all elements of $a and $b are
themselves immutable to all levels of
recursion, === then does a full deep copy like
eqv. If at any level we get a mutable object,
then at that point it turns into =:= (a trivial
case) and stops.
( 1, "2.0", 3 ) === ( 1,2,3 )
True or false?
That would be false, because a Str does not === an Int.
I should point out, though, that in at least some
situations where you are ===, you would have more
control of the creation of the structures in the
first place and they will probably have been
created in a more strict fashion that required
the data to be of corresponding types in the
first place. Eg, each Seq would have only been
allowed to store Ints in the first place. The
best place to normalize input is as early as
possible, after all, like when the Ints were
input and before they were put in the Seq to be
compared.
More imprtantly, how do I tell perl what I mean? The best I can think of is:
[&&] (@a »==« @b)
Vs
[&&] (@a »eq« @b)
But this only works for nice flat structures.
For arbitrary tree structures, we probably need
adverbs on a comparison op (I think Larry
mentioned this a few posts back) ... but if
we're going with adverbs do we really need 5
different base operators? Are all of the 5 so
common that it would be clumbersome to require
adverbs for their behavior?
Also, when sorting things, maybe deep inequalities would be useful, too.
I will punt on that one.
-- Darren Duncan