🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

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

Re: Taking operator overloading too far?

#130
From: Thomas Maeder [TeamB]
Date: Tue, 01 Feb 2005 16:25
40 lines
2728 bytes
"Andrue Cope [TeamB]" <no.spam@not.a.valid.address> writes:

> In one configuration this equates to comparing two directory trees and
> I had this idea of overloading the '==' operator for the class that we
> already have that we use to iterate directory trees.
>
> In pseudo code this might be:
>
>   TOVolIO_DirectoryTree src( "c:\\" ),
>                         trg( "d:\\" );
>
>   if( src==trg )
>     ShowMessage( "The directory trees are identical" );

Not sure if I like it.

First (and not so important), == tests for equality, not identity. You
compare addresses or identifying attributes to test for identity.


Second, it's not clear to me what equality means. Do the files in the
tree have to have the same content, or also the same creation and
access times? What about permissions?


> 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)?

Not necessarily. == applies to much more types than < and >.
E.g. std::find requires the value_type to be comparable using ==. <
and > are not required.


> 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.

Using * for multiplying matrices feels very natural, doesn't it?
Technical Details
Message-ID: <m2zmyop7rq.fsf@madbox2.local>
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news.zanker.org!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!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: maeder@glue.ch (Thomas Maeder [TeamB])
Organization: TeamB
X-Face: ":yn4zt^A_dn>6~{YJmu^B\'4w)e:apPM\VC=Dvf&*tASxX9|BYczkFd$xr.$vNSZ[3Uobr p]c4\+\l){!WQI.$]veP({HLd;CDYH?iN
Date: Tue, 01 Feb 2005 17:25:13 +0100
Message-ID: <m2zmyop7rq.fsf@madbox2.local>
User-Agent: Gnus/5.1006 (Gnus v5.10.6) XEmacs/21.4 (Corporate Culture,
 linux)
Cancel-Lock: sha1:aI37sPcjDyRNoAelDygcmnN6T+8=
MIME-Version: 1.0
Content-Type: text/plain; charset=us-ascii
NNTP-Posting-Host: 80.218.114.55
X-Trace: newsgroups.borland.com 1107275116 80.218.114.55 (1 Feb 2005 08:25:16 -0800)
Lines: 40
X-Authenticated-User: tmaeder
Path: arc1-ca.pugleaf.net!g2news1.google.com!news4.google.com!news.glorb.com!news.zanker.org!feeder.enertel.nl!nntpfeed-01.ops.asmr-01.energis-idc.net!216.196.110.149.MISMATCH!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