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.227.166 with SMTP id sb6mr3590391pbc.4.1331165466811; Wed, 07 Mar 2012 16:11:06 -0800 (PST) MIME-Version: 1.0 Path: h9ni51493pbe.0!nntp.google.com!news1.google.com!goblin1!goblin3!goblin.stu.neva.ru!gegeweb.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 18:11:01 -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> <87mx80x03h.fsf@ludovic-brenta.org> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1331165465 9663 69.95.181.76 (8 Mar 2012 00:11:05 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 8 Mar 2012 00:11:05 +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-07T18:11:01-06:00 List-Id: "Robert A Duff" wrote in message news:wcclinkxvth.fsf@shell01.TheWorld.com... > Ludovic Brenta writes: > >> Robert A Duff writes on comp.lang.ada: >>> Foo (Slide(A (3 .. 8))); >> >> Doesn't that involve copy-in and copy-out between the slice and a >> temporary object of type Slide? Grossly inefficient, methinks. > > No, I don't see any need for the compiler to make a copy here. > It just needs to pass the 1..6 bounds, plus a pointer to > the array elements. > > I'm too lazy to check the machine code to see whether GNAT > makes a copy, but I don't see why it would. Nor any other > Ada compiler. Surely Janus/Ada does not. It just makes a new array descriptor and passes that -- exactly the same as it would do for the original slice. The only interesting question is whether Janus/Ada would be smart enough to get rid of the (unused) original slice's array descriptor. I didn't check, but I'm sure there wouldn't be one in this case (static bounds). I have no idea what would happen if the bounds were dynamic (as in my better example). Randy.