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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,703c4f68db81387d X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news4.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Magic ordering Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <4229bad9$0$1019$afc38c87@news.optusnet.com.au> <87r7iu85lf.fsf@insalien.org> <1110052142.832650@athnrd02> <42309456$1@news.broadpark.no> <4232ab3a$0$26547$9b4e6d93@newsread4.arcor-online.net> <1110888090.283361.113590@z14g2000cwz.googlegroups.com> <11gvzgwy0zc0d$.zmffiqh7xd48$.dlg@40tude.net> Date: Tue, 15 Mar 2005 18:52:10 +0100 Message-ID: <1if87duous7mi.14wuswc50g03i$.dlg@40tude.net> NNTP-Posting-Date: 15 Mar 2005 18:52:09 MET NNTP-Posting-Host: 6df0cebe.newsread2.arcor-online.net X-Trace: DXC=ObXbg=3M[>NfS]5RcNSd9MQ5U85hF6f;DjW\KbG]kaMHliQbn6H@_EI^4Qc<5lSP`AWRXZ37ga[7Jeh9Z=IkP^1DKDeZU>XgY1E X-Complaints-To: abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:9450 Date: 2005-03-15T18:52:09+01:00 List-Id: On Tue, 15 Mar 2005 16:21:25 +0000, Marius Amado Alves wrote: > On 15 Mar 2005, at 15:08, Dmitry A. Kazakov wrote: >> There could be many orders defined on the same objects, as Hyman >> rightfully pointed out. But any of them have to be published in the contract. >> There is nothing outside the contract. > > There may be multiple contracts overlapping, or even disjoint, > associated with the same type. I would say that are subtypes of the type. > That's how most systems are constructed. > For example a part of the program gives you a contract for the deep > meaning e.g. retrieve the person's name given the SS number. Another > part is a contract that ascertains if the number is in a given set. > They overlap. The latter does not need the name. The former does not > need the set. I know this design is not an OO pearl, but it works, > there's nothing wrong with it, and is present in most systems I've seen > or built. This is how Ada generics work. When instantiated you can reroute operations to satisfy the contract. It is also possible to do with tagged types, no wrappers needed: type X is tagged null record; function "<" (Left : X; Right : X'Class) return Boolean; function ">" (Left : X; Right : X'Class) return Boolean; type Y is new X with null record; -- Swap "<" and ">" function Less (Left : Y; Right : X'Class) return Boolean renames "<"; function Greater (Left : Y; Right : X'Class) return Boolean renames ">"; function "<" (Left : Y; Right : X'Class) return Boolean renames Greater; function ">" (Left : Y; Right : X'Class) return Boolean renames Less; > On the (non-OO) extreme of this theory, there are no objects, just > operations, a subset of which constitute each contract (well, each > interface). I've been using formal packages a lot lately as an > approximation of this. But that's the same. Whether it be stated or deduced contract, there is one. The only difference is that the latter cannot be efficiently evaluated neither by the compiler nor by the programmer. > But we diverted very quickly from the mainline, creating an order for a > type. As I said, I believe there's always a way: but it must be done > case by case. Show me your type, and I'll show you a way. If there's no > way I'll ask you: why do you want to order this type? If you show a > good reason, I'll (hopefully) be able to identify the design fault. OK but it is responsibility of the type designer to provide you with a comparison. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de