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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c3a7c1845ec5caf9 X-Google-Attributes: gid103376,public From: bobduff@world.std.com (Robert A Duff) Subject: Re: Equality operator overloading in ADA 83 Date: 1997/04/25 Message-ID: #1/1 X-Deja-AN: 237280203 References: <01bc4e9b$ac0e7fa0$72041dc2@lightning> <335F5971.6375@elca-matrix.ch> <33671d9c.5046069@news.airmail.net> Organization: The World Public Access UNIX, Brookline, MA Newsgroups: comp.lang.ada Date: 1997-04-25T00:00:00+00:00 List-Id: In article <33671d9c.5046069@news.airmail.net>, Kevin Cline wrote: >You should know. All comparison functions used by a generic should be generic >formal parameters with defaults. Probably a good idea for "<" and sorting. But it doesn't solve the problem. How does the compiler know whether the generic is making certain assumptions (like "A < B and B < C" implies "A < C")? We're talking about language semantics, here: you either have to define precise language rules that ensure the above property, or you have to say what happens if that property doesn't hold (and lots of other properties one could imagine). It's not fair to rely on programmer's good taste. Do you believe that Text_IO.Integer_IO should have generic formal functions for "+", "/", "mod", etc? Even if it did, you still wouldn't know exactly how they are used without looking at the generic body (which I'm afraid is not in the RM). There are many different algorithms for converting integers to string form, and redefining "/" might break some such algorithms, and not others. >>OK, but then if I redefine "<" on a scalar type, should ">=" change? >>After all, ">=" is (or could be) defined as "not <". > >Only for totally-ordered sets. It is useful to redefine "<" and ">" to model >partial orderings, in which case >= is not equivalent a < b. We're talking about what the language semantics should do automatically for you. You have to say "yes" or "no". You can't say "only for totally-ordered sets" (unless you give the compiler some way of telling whether you meant it to be a totally-ordered set, which sounds like a can of worms to me). - Bob