From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.129.123.85 with SMTP id w82mr7179036ywc.39.1444911852588; Thu, 15 Oct 2015 05:24:12 -0700 (PDT) X-Received: by 10.182.44.163 with SMTP id f3mr86594obm.7.1444911852556; Thu, 15 Oct 2015 05:24:12 -0700 (PDT) Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!feeder.eternal-september.org!news.glorb.com!5no1297581qgg.0!news-out.google.com!z4ni21716ign.0!nntp.google.com!kq10no21627466igb.0!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Thu, 15 Oct 2015 05:24:12 -0700 (PDT) In-Reply-To: <87mvvla5ma.fsf@bsb.me.uk> Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=213.108.152.51; posting-account=bMuEOQoAAACUUr_ghL3RBIi5neBZ5w_S NNTP-Posting-Host: 213.108.152.51 References: <5cb5c989-4d12-41d8-88df-ab45988ba8a1@googlegroups.com> <87mvvla5ma.fsf@bsb.me.uk> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <8f252b53-4d99-4d4c-893c-66ec29ec38d6@googlegroups.com> Subject: Re: Top 10 Worst C# Features From: Maciej Sobczak Injection-Date: Thu, 15 Oct 2015 12:24:12 +0000 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Xref: news.eternal-september.org comp.lang.ada:27982 Date: 2015-10-15T05:24:12-07:00 List-Id: > Do you mean that there are reasons to permit !(a =3D=3D b) and a !=3D b t= o > have different values in some cases? Why not? We are already talking about the language where a+b is not necessa= rily equal to b+a (hint: strings). ;-) There is also an interesting area for objects that might be neither "equal"= nor "different" (that is, where both operators might return false at the s= ame time). As an illustration, Apples and Oranges are neither equal nor different, eve= n though they are all Fruits and might be modeled in a flat type system. Of course, diverting from the usual laws is asking for trouble, but as I ha= ve already said - some programmers might be willing to get some added flexi= bility at the expense of higher verification effort. Definitely, one should= not automatically assume that all C++ programmers are morons. > I don't see why >=20 > bool operator!=3D(const T &other) const noexcept > { > if (this.hash !=3D other.hash) > return true; > return !this.long_slow_equality_test(other); > } >=20 > is any more or less efficient than >=20 > bool operator=3D=3D(const T &other) const noexcept > { > if (this.hash !=3D other.hash) > return false; > return this.long_slow_equality_test(other); > } >=20 > but I may have missed the point you are trying to make. No, but you have missed the point that I tried to address. Your example is = OK with regard to performance, but for some reason you have still used *dis= tinct* implementations of these operators, instead of calling one from anot= her. And interestingly, your WCET is even worse than in my example, as it m= ight need to execute two comparisons (fast and slow) instead of just the on= e which is asked for. Of course, I don't claim that these are typical usage scenarios. Typically,= these operators indeed should be based on common logic. --=20 Maciej Sobczak * http://www.inspirel.com