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 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!mx02.eternal-september.org!.POSTED!not-for-mail From: Ben Bacarisse Newsgroups: comp.lang.ada Subject: Re: Top 10 Worst C# Features Date: Wed, 14 Oct 2015 20:54:13 +0100 Organization: A noiseless patient Spider Message-ID: <877fmp9qfu.fsf@bsb.me.uk> References: <5cb5c989-4d12-41d8-88df-ab45988ba8a1@googlegroups.com> <87mvvla5ma.fsf@bsb.me.uk> <87si5d1jiw.fsf@jester.gateway.sonic.net> Mime-Version: 1.0 Content-Type: text/plain Injection-Info: mx02.eternal-september.org; posting-host="017616aa25f81ec581c44d76d61ba2f3"; logging-data="16635"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1/Z88hSxY/YfRPdFDlP3Z2vXxDmWKg/26M=" Cancel-Lock: sha1:qLfSkGLifbsEc/jbfawfMgaiTI4= sha1:y74t24lSh7uPVLpoFt96UPBmdkU= X-BSB-Auth: 1.9cc6063e65edb410272a.20151014205413BST.877fmp9qfu.fsf@bsb.me.uk Xref: news.eternal-september.org comp.lang.ada:27978 Date: 2015-10-14T20:54:13+01:00 List-Id: Stefan.Lucks@uni-weimar.de writes: > On Wed, 14 Oct 2015, Paul Rubin wrote: > >> Ben Bacarisse writes: >>> Do you mean that there are reasons to permit !(a == b) and a != b to >>> have different values in some cases? >> >> I think he meant they should both return the same value, but it is ok if >> they don't use the same algorithm. Of course it may be possible for the >> compiler to optimize the first into the second. The idea is just that >> if (a != b) { ... } can be much faster than if (a == b) { ... } . > > As I seem to understand, Ben questioned that either the test on > equality or on non-equality could be much faster than the other one. Yes, exactly. If !(a == b) and a != b don't have to be the same for this imagined type then of course one can be faster than the other, but if the usual laws are to hold, implementing one can't be anything but trivially easier then the other. -- Ben.