On Nov 11, 2005, at 3:06 AM, Balázs Szabó (dLux) wrote:
$x = $_[0];
$x is created, a new obj in year 2000. (via clone() inside
Class::Date)
Not correct. $_[0] is always points to the same object as $a, $_[1]
always points to the same object as $b; In this case, we have a new
object, $x, which is also points to the same as $a and $_[0];
Oh. At a glance inside the guts of your class and not knowing
"overload" well I thought Class::Date was doing operator overloading
on the assignment operator (=), invoking clone().
Now I've read up a little (perldoc overload) and may understand your
guts better. Your explanation above explains that the assigment above
is a vanilla Perl reference assignment, not some deep overloaded
magic...
This part of "perldoc overload" wigs me out:
SPECIAL SYMBOLS FOR "use overload"
...
Copy Constructor
The value for "=" is a reference to a function with three
arguments,
i.e., it looks like the other values in "use overload".
However, it
does not overload the Perl assignment operator. This would go
against
Camel hair.
"would go against camel hair?" lol! Jay swoons w/ bemused
incomprehension. I thought NOTHING was sacred inside overload. -laugh-
Debugging your class objects always trips me up because of your (very
useful)
use overload
'""' => "string",
I'm used to debugging and seeing this:
DB<1> p $x
main=HASH(0x8d3a28)
But on your objects I get this:
DB<2> p $a
2000-11-11 00:00:00