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.74.201 with SMTP id w9mr3596882pbv.0.1331164731524; Wed, 07 Mar 2012 15:58:51 -0800 (PST) MIME-Version: 1.0 Path: h9ni51454pbe.0!nntp.google.com!news1.google.com!goblin1!goblin2!goblin.stu.neva.ru!aioe.org!news.ecp.fr!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: Wed, 7 Mar 2012 17:58:41 -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 1331164727 8935 69.95.181.76 (7 Mar 2012 23:58:47 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Wed, 7 Mar 2012 23:58:47 +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-07T17:58:41-06:00 List-Id: "Robert A Duff" wrote in message news:wccy5rls0hl.fsf@shell01.TheWorld.com... > stefan-lucks@see-the.signature writes: ... > Sure, slices are useful, and I use them. But I wouldn't mind too > much if they didn't exist. It's trivial to write a Slice function > that does what "A(F..L)" does. In Ada 2012, it's not that hard to write a Slice_LValue function that would let you assign into A(F..L). It's in fact the key to my half-formed Root_String'Class proposal (plus the indexing features already in Ada 2012 - the only thing missing is string literals). > You didn't address my point about l-values. None of your slices > above are l-values. L-value slices cause a lot of implementation > trouble, and are nearly useless -- the language would be better > off without them. I don't buy this at all. I've tried using loops instead of slices to do string manipulation (early Janus/Ada didn't have slices), and the results had horrific readability and performance. Even today, the optimization of slices is much better than the optimization of the supposedly equivalent loop (mainly because no optimization is needed to optimize the slice; the code is already nearly optimal when created by the Janus/Ada front end). Obviously, this could be different on a different Ada compiler, but I'm at least a bit skeptical. >> On the other hand, I agree that the fact that array slices carry their >> original indices with them is a misfeature of Ada. >> >> I would appreciate way to convert ingoing parameters into some standard >> indexing. For example (inventing a new syntax variant on the fly): >> >> 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. I suppose a more convinient way to force that would be helpful. Randy.