🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.oodesign
Article #128

Re: Taking operator overloading too far?

#128
From: Chris Uzdavinis
Date: Tue, 01 Feb 2005 15:49
45 lines
3104 bytes
"Andrue Cope [TeamB]" <no.spam@not.a.valid.address> writes:

> The main objection I have to this is that if you overload '=='
> shouldn't you also overload '>' etc. (and what would '>' mean in this
> context come to that)?


I wouldn't worry about adding needless, hard-to-define operations.
Being able to tell if two things are equivalent is considerably
different than being able to put them into a meaningful "order".

Think of math equations.  Either they are equivalent, even if they are
represented differently, or they're different, but it's hard to say
which math expression should come "first".  Unless you define
specifically what it means for an ordering, creating one artificially
seems a waste of time, is confusing, and probably will lead to more
surprises than useful results.

> I know that the language doesn't require it (in the sense that as
> long as no one tries to use them there's no problem) but I've always
> felt that if you overload one relational operator it is best
> practice to overload them all.

That may be true for things that you want to sort, or put in certain
STL containers, etc., but I see no reason to invent operations that
have no meaning to appease a design heuristic that probably doesn't
fit in this case anyway.

> The other objection I have is perhaps even more trivial. It somehow
> feels 'wrong' to have calling an operator result in such a large amount
> of activity. Then again the algorithm almost writes itself since of
> course the file handling objects will also have an '==' overload.

I know what you mean, though it's hard to quantify.  For some reason,
operators have the apperarance of doing little.  Perhaps it's because
they're relatively detached from the objects on which they operate.
That is, syntactically, they're not connected to the object in a way
that calling a normal member function is.  They're easy to overlook,
in that regard.

But if you're really testing for equality/equivalence (it's important
to be clear which you decide), then why not?

-- 
Chris (TeamB);
Technical Details
Message-ID: <j57jlsuvpd.fsf@explicit.atdesk.com>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-in.ntli.net!newsrout1-win.ntli.net!ntli.net!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail
References: <41ff924d@newsgroups.borland.com>

Show Full Headers
Complete Article Headers
X-Google-Thread: 10db1e,6c4cb604a6b19d7
X-Google-Attributes: gid10db1e,public
X-Google-Language: ENGLISH,ASCII-7-bit
Newsgroups: borland.public.cppbuilder.oodesign
Subject: Re: Taking operator overloading too far?
References: <41ff924d@newsgroups.borland.com>
From: Chris Uzdavinis (TeamB) <chris@uzdavinis.com>
Organization: TeamB
Date: Tue, 01 Feb 2005 10:49:18 -0500
Message-ID: <j57jlsuvpd.fsf@explicit.atdesk.com>
User-Agent: Gnus/5.1002 (Gnus v5.10.2) Emacs/21.2 (gnu/linux)
Cancel-Lock: sha1:sC0ow+FeyFSQf4G+t0IB4c5wEn4=
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
NNTP-Posting-Host: 63.68.0.194
X-Trace: newsgroups.borland.com 1107272957 63.68.0.194 (1 Feb 2005 07:49:17 -0800)
Lines: 45
Path: arc1-ca.pugleaf.net!g2news1.google.com!news3.google.com!news.glorb.com!news-in.ntli.net!newsrout1-win.ntli.net!ntli.net!border2.nntp.ams.giganews.com!nntp.giganews.com!pe2.news.blueyonder.co.uk!blueyonder!news-peer-test!btnet!newsfeed.bt.es!caladan.landsraad.net!newsgroups.borland.com!not-for-mail