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=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,8ffd9ca0013db6a7 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2000-10-30 19:34:57 PST Path: supernews.google.com!sn-xit-02!sn-xit-03!supernews.com!cabal10.airnews.net!news.airnews.net!news.mindspring.net!firehose.mindspring.com!not-for-mail From: Lao Xiao Hai Newsgroups: comp.lang.ada Subject: Re: Redefined "=" = generic disaster? Date: Mon, 30 Oct 2000 19:27:49 -0800 Organization: MindSpring Enterprises Message-ID: <39FE3C35.64CBB3C7@ix.netcom.com> References: <39F13ED9.1EE@li.net> <39F1C092.87D4135E@acm.org> <39F1F686.26B5@li.net> <8tecab$epm$1@nnrp1.deja.com> <39FCEFAD.56BE85B1@ix.netcom.com> <8tkfme$v8a$1@nnrp1.deja.com> NNTP-Posting-Host: 3f.35.af.e0 Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Server-Date: 31 Oct 2000 03:33:15 GMT X-Mailer: Mozilla 4.7 [en] (Win98; I) X-Accept-Language: en Xref: supernews.google.com comp.lang.ada:1650 Date: 2000-10-31T03:33:15+00:00 List-Id: Robert Dewar wrote: > In article <39FCEFAD.56BE85B1@ix.netcom.com>, > Lao Xiao Hai wrote: > > Could not resist posting this package specification and body > > in response to your challenge Robert. > > OK, you posted the code. My request was to post code that did > something other than what you would expect from reading the > code. I can't see that this is true, but then I am not > telepathic, I cannot guess what peculiar expectations you > might have. > > Please explain why this code does something different from > what you expect? As I recall, the discussion had something to do with unreliable expectations with regard to overloading the equality operator. It is true that someone reading my example would have no particular expectation. It is also true that your selection of the word "peculiar" to describe the example is appropriate. The point of the posting is that one can certainly overload the equality operator in strange ways and those can be coded so as to obfuscate any reasonable meaning. It is a short step from there to obfuscation of the intended meaning. Sadly, there are those among us (mostly in the C++ world, I suppose), who seem to delight in obfuscated code. In other cases, someone does it thoughtlessly. Just today, someone showed me a package specification in which he had overloaded the equality operator for a generic formal record parameter. What he intended the equality operator to do and what one might have reasonably expected were far from the same. I suggested the following, to coincide with his intentions. Instead of, function "=" (L, R : Item) return Boolean; he needed, function Key_Is_Equal(L, R : Item) return Boolean; With this operation, any user knows what to expect of the contract. That is often not the case with overloading of the "=" by itself. Richard Riehle