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: fac41,953e1a6689d791f6 X-Google-Attributes: gidfac41,public X-Google-Thread: f79bb,953e1a6689d791f6 X-Google-Attributes: gidf79bb,public X-Google-Thread: 103376,953e1a6689d791f6 X-Google-Attributes: gid103376,public From: eachus@spectre.mitre.org (Robert I. Eachus) Subject: Re: Eiffel and Java Date: 1996/11/04 Message-ID: #1/1 X-Deja-AN: 194417326 references: <550sm2$sn1@buggy.news.easynet.net> followup-to: comp.lang.eiffel,comp.lang.ada,comp.lang.sather organization: The Mitre Corp., Bedford, MA. newsgroups: comp.lang.eiffel,comp.lang.ada,comp.lang.sather Date: 1996-11-04T00:00:00+00:00 List-Id: In article <55crp0$qn9@dscomsa.desy.de> mernst@x4u2.desy.de (Matthias Ernst) writes: > All languages that unify inheritance and subtyping enforce that > once you inherit from a class you build a subtype. There are > several examples (mostly with binary methods and the type Self, > SAME, like Current or whatever) that show that it may be the > implementation you are interested in but you can't guarantee > subtype relationship. > class Comparable > is > "<="(other: Self): Bool is abstract; > ">="(other: Self): Bool is other <= self end; > ">"(other: Self): Bool is ~(self <= other) end; > "<"(other: Self): Bool is other > self end; > end;... I think I understand what you want here, but it works fine in Ada 95: package Compare is type Comparable is tagged private; function "<=" (L,R: Comparable) return Boolean is abstract; function ">=" (L,R: Comparable) return Boolean; function ">" (L,R: Comparable) return Boolean; function "<" (L,R: Comparable) return Boolean; private type Comparable is null record; end Compare; package body Compare is function ">=" (L,R: Comparable) return Boolean is begin return R <= L; end ">="; function ">" (L,R: Comparable) return Boolean is begin return not (L <= R); end ">"; function "<" (L,R: Comparable) return Boolean; begin return not (R <= L); end "<"; end Compare; For types derived from Comparable, you only need to define the one inequality operation. The other possibility is that you want a generic template. That works in Ada 95 as well: generic type Comparable is tagged private; with function "<=" (L,R: Comparable) return Boolean is <>; package Compare is function ">=" (L,R: Comparable) return Boolean; function ">" (L,R: Comparable) return Boolean; function "<" (L,R: Comparable) return Boolean; end Compare; package body Compare is -- (same as above) I went through all this because it is one of the cases where the symmetric Ada notation does have technical advantages. -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...