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=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2ac407a2a34565a9 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.235.4 with SMTP id ui4mr964039pbc.3.1331258553920; Thu, 08 Mar 2012 18:02:33 -0800 (PST) MIME-Version: 1.0 Path: h9ni4519pbe.0!nntp.google.com!news2.google.com!goblin3!goblin.stu.neva.ru!nntp-feed.chiark.greenend.org.uk!ewrotcd!reality.xs3.de!news.jacob-sparre.dk!munin.jacob-sparre.dk!pnx.dk!.POSTED!not-for-mail From: "Randy Brukardt" Newsgroups: comp.lang.ada Subject: Re: Array Help? Date: Thu, 8 Mar 2012 20:02:27 -0600 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: References: <10615783-d4a9-4cbd-8971-53ba1100d6a0@b18g2000vbz.googlegroups.com> <17412419.40.1330534213855.JavaMail.geo-discussion-forums@vbva11> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1331258552 16255 69.95.181.76 (9 Mar 2012 02:02:32 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 9 Mar 2012 02:02:32 +0000 (UTC) X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2900.5931 X-RFC2646: Format=Flowed; Original X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.6157 Date: 2012-03-08T20:02:27-06:00 List-Id: wrote in message news:Pine.LNX.4.64.1203081150460.6571@medsec1.medien.uni-weimar.de... > On Wed, 7 Mar 2012, Randy Brukardt wrote: > >> "Robert A Duff" wrote in message >> news:wccy5rls0hl.fsf@shell01.TheWorld.com... >> > stefan-lucks@see-the.signature writes: >> >> procedure Sort(Items: in out array(generic Positive range <>) of T) >> >> is >> > >> > Interesting idea. >> >> Can't you do this with a type conversion to an appropriate constrained >> array >> subtype? (Such conversions slide.) I suppose it could be a pain to >> declare >> such a subtype in front of every call, but it is a trick I've used a some >> cases (usually in wrappers) to force sliding on arguments. > > Can you explain a bit more? Bob and I both gave examples of it in other messages. >> I suppose a more convinient way to force that would be helpful. > > Beyond the inconvenience, there are two further issues: > > 1. Testing > > When you declare > > procedure Sort(Items: in out array(Positive range <>) of T) Let's hope you never do that, because anonymous types are the bane of Ada. And you surely can't do it today! > in a package specification, and you try to write a proper black-box test, > you need *more* test cases then when you do the same with another popular > language. Right. Bob's suggestion for some semi-constrained array subtype would fix that. But note that it was killed in Ada 95 in part because the implementation needed was essentially a record type with some sort of magic indexing. Which was a mess. Not sure if those issues can really go away, and I doubt there is much interest in new first-class kinds of constraints. ... > 2. Generality > > Given the (Ada 2020?) specification > > procedure Sort(Items: in out array(generic Positive range <>) of T); Again, anonymous types are a disaster in Ada, and there is no way that we should have more of them. I would strongly hope that this never appears even in Ada 2525. ;-) > Sort(X) should be callable if the index type of X is any discrete type, > except when the index type is too large (i.e., X has more than > Positive'Last elements). If you want that, you need to declare that. Positive is a numeric type, and thus has "+" and "-" available; it is never going to be allowed to match "any discrete type" which includes enumeration types. It's plenty easy to write a generic like this (see the predefined ones for examples), so I fail to see what possible need you are addressing here. Randy.