[Kde-perl] Overloading of operators '==' and '!='

Johannes Plass johannes.plass at web.de
Sat May 22 20:30:27 CEST 2004


Hi all,

being a PerlQt noob I would like to send a big
"Thank You for this wonderful software" to the
PerlQt developers, maintainers, supporters and
documentation writers (did I miss someone ?).
This is really a tool that saves me about
48 hours a day .....

Enough praising, here's a tiny recommendation
I would like to throw into the discussion pool:

In PerlQt the copy constructor ('=') isn't overloaded
since "it clashes with the perl paradigm" (as stated
in the Changelog of 3.006).
Now, for the same reason, I'd like to recommend to
drop the overloading of operators '==' and '!='.
The operators as they act now cause a loss of
the object's identity based on reference comparison.

Example:
Create a subclass MyPoint of Qt::Point, then construct
lots of MyPoint objects and stuff them in a list.
Now you're in trouble when you want to find
a specific object in this list (for instance in order
to remove it), since code like
     if ($list[$i] == $mypoint) ...
doesn't check the identity of the references but the
equalness of the objects x and y coordinates.

Deactivation of the overloading can be achieved by commenting
out the two lines
     "==" => "Qt::base::_overload::op_equal",
     "!=" => "Qt::base::_overload::op_not_equal",
in Qt.pm (at least it works without side effects I'm
aware of).
Perhaps it is possible to include that in the next version
of PerlQt ?

Greetings and thanks again for this wonderful development tool

Johannes


More information about the Kde-perl mailing list