logo       

Re: Overloading of operators '==' and '!=': msg#00006

Subject: Re: Overloading of operators '==' and '!='
--- Johannes Plass <johannes.plass@xxxxxx> wrote:
> 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 ?

I wonder how painful the transition to correctness would be. You are
quite right that using == and != for content comparisons doesn't match
Perl's operator meanings.

>From a design perspective, any class with the serialization
QDataStream& operator <<() functions should have string comparison
operators which "apparently" act upon their serialized representations.
Therefore, content comparison should have been implemented with C<eq>
and C<ne>, and referential comparison should have been left with Perl's
default C<==> and C<!=>. In fact, there might even be some use to
creating a default implementation of C<cmp> which attempts to serialize
both sides of the operator and perform a string comparison on them, in
the absence of specific comparison operators from Qt.

I would stop short of actually overloading the '""' stringification
operator, simply because I see no point to it. However, how about
replacing the C++ evilness of << for serialization with C<.>?

$x = $point1 . $point2 . $point3;   # $x is QDataStream, now

The inverse operation should be implemented by hijacking the
constructor for serializable objects:

$point1 = Qt::Point($x);
$point2 = Qt::Point($x);
$point3 = Qt::Point($x);

Or, if we want it even more explicit:

$point1 = Qt::Point <$x>;
$point2 = Qt::Point <$x>;
$point3 = Qt::Point <$x>;

Thereby making the destructive/iterative nature of the operation clear
to Perl-Folk. However, given the syntactic limitations of perl's <>
operator (only a simple $scalar variable allowed), both should be
permissable.

/end design brainstorm

Ashley Winters


        
                
__________________________________
Do you Yahoo!?
Yahoo! Domains ? Claim yours for only $14.70/year
http://smallbusiness.promotions.yahoo.com/offer 


<Prev in Thread] Current Thread [Next in Thread>
Google Custom Search

Recently Viewed:
linux.arklinux....    user-groups.lin...    kde.usability/2...    ietf.ipp/2002-0...    mail.spam.spamc...    os.netbsd.devel...    audio.cd-record...    text.unicode.de...    php.documentati...    games.fps.halfl...    window-managers...    suse.oracle.gen...    bug-tracking.gn...    video.dvdrip.us...    xfree86.cvs/200...    java.netbeans.m...    network.argus/2...    culture.sf.kill...    debian.ports.al...    freebsd.questio...    qplus.devel/200...    handhelds.palm....   
Home | blog view | USPTO Patent Archive | advertise | OSDir is an inevitable website. super tiny logo

Free Magazines

Cisco News
Receive a free quarterly e-newsletter with exclusive articles on how Cisco IT uses its own products and solutions to enable the business.
subscribe

Systems Management News, the newspaper for IT systems administration and data center managers! Each issue of Systems Management News is chock-full of news and analysis to help you understand what's happening in your field.
subscribe

The Enterprise Newsweekly eWeek is the essential technology information source for builders of e-business.
subscribe

Oracle Magazine Oracle Magazine contains technology strategy articles, sample code, tips, Oracle and partner news, how to articles for developers and DBAs, and more. Oracle (NASDAQ: ORCL) is the world's largest enterprise software company.
subscribe

Total Telecom Total Telecom is "The Economist of the communications industry".
subscribe