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,91276ec2ea911d3f X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news2.google.com!news.germany.com!newsfeed.utanet.at!newsfeed01.chello.at!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Generic procedures and their parameters Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.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: Date: Fri, 8 Sep 2006 09:21:44 +0200 Message-ID: NNTP-Posting-Date: 08 Sep 2006 09:21:43 CEST NNTP-Posting-Host: 1576db58.newsspool3.arcor-online.net X-Trace: DXC=Om_g1Wfid2cf1oJaJ0@dmgMcF=Q^Z^V3h4Fo<]lROoRa4nDHegD_]Re]Z4FkTfB On Thu, 7 Sep 2006 22:35:44 -0500, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:w0vh1ugsvkj1$.2fnx5mt0tplm$.dlg@40tude.net... > ... >> The reverse is a different story. It is a pity that Ada does not have >> attributes to get the index and element types from the array type >> (container type). The next step would be getting "<" from the element type, >> which would eliminate a need to have Sort generic. > > That doesn't really work. "<" is what controls how the items are sorted, and > it is common to want to sort the same type in multiple ways. If you have > employee records, you might want to sort them both on Social Security > numbers and on date of employment, for example. Two generic instantiations > work fine for that, but there isn't any way to have two "<" with different > behaviors. > > We had this discussion when looking at the possibility of having a sorting > interface. It just doesn't work well, because there can only be a single > implementation. (That is a problem with any scheme based on inheritance.) > That's why I view interfaces less as types and more as properties that are > either present or absent on any individual specific type. Yes, that's when somebody wanted to have different orders. But that in my view is a different case, in which "<" should be better passed to Sort as a plain parameter, rather than generic or primitive subprogram. I think the difference between two scenarios is whether the order is arbitrary, ad-hoc or else involved in some loose set of operations. In the first case "<" should be a parameter in the latter case a part of the interface (be it generic or primitive operation). -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de