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!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "J-P. Rosen" Newsgroups: comp.lang.ada Subject: Re: A bad counterintuitive behaviour of Ada about OO Date: Fri, 08 Aug 2014 14:00:26 +0200 Organization: A noiseless patient Spider Message-ID: References: <932kntuq5rrr.8sumwibqrufn.dlg@40tude.net> <1ohy7vnbntskq$.h139ov04mlxu$.dlg@40tude.net> <17wt4z4suijym$.fibkp6sw5itz$.dlg@40tude.net> <1k6qcfme6203h.1jon846ebrywu$.dlg@40tude.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit Injection-Date: Fri, 8 Aug 2014 12:00:29 +0000 (UTC) Injection-Info: mx05.eternal-september.org; posting-host="23dab0694e4174fdc880833ec67fa650"; logging-data="8080"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+uwiEtbp9k0ybcu59uQQ36" User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: Cancel-Lock: sha1:uqQqzLIR166sI/h2vwY3nsiIHdQ= X-Enigmail-Version: 1.6 Xref: news.eternal-september.org comp.lang.ada:21548 Date: 2014-08-08T14:00:26+02:00 List-Id: Le 08/08/2014 12:53, Dmitry A. Kazakov a écrit : >> Moreover, classification is used in mathematics for the theory of >> numbers, which is not relevant to practical usage of numbers. > > Having integers ordered is unpractical? Being them additive has no usage? > Yes of course, but the /theory/ of it, and especially group theory etc. that you mentioned is not a programmer's concern. > I don't know which relationships are "conceptual" and which are not. > > generic > type Element_Type is private; > with function "<" (Left, Right : Element_Type) return Boolean is <>; > with function "=" (Left, Right : Element_Type) return Boolean is <>; > package Ada.Containers.Ordered_Sets is > > Isn't all types acceptable as Element_Type a "conceptual" class? > I argue they are not. If you provide an operation that operates on a class wide type, then it can be used only on types belonging to the class, which means there is a dependency between these types. A generic can be applied to types that are not related in any way. This reminds me of a (bad) example of inheritance I once saw in a book: the class "parrot" inherited from the class "human" because it needed the method "can_speak". I'm somewhat uncomfortable with the notion that a parrot is a special kind of human ;-). Well, it's a bad example because inheritance should not be used just to grab any method you need. There must be some /conceptual/ dependence, i.e. some "is-a" dependency. That's what I meant: a generic "can_speak" function that could be instantiated on humans or parrots would be much less disturbing - to my taste. -- J-P. Rosen Adalog 2 rue du Docteur Lombard, 92441 Issy-les-Moulineaux CEDEX Tel: +33 1 45 29 21 52, Fax: +33 1 45 29 25 00 http://www.adalog.fr