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,32d9aa9d79729b31 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.196.232 with SMTP id ip8mr15713033pbc.6.1341649337255; Sat, 07 Jul 2012 01:22:17 -0700 (PDT) Path: l9ni11068pbj.0!nntp.google.com!news1.google.com!goblin2!goblin.stu.neva.ru!aioe.org!.POSTED!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: Any easy/build-in construct to extract submatrices from larger matrix? Date: Sat, 7 Jul 2012 10:22:06 +0200 Organization: cbb software GmbH Message-ID: <4v47r111x0z6$.ht7gkeuc7hr6$.dlg@40tude.net> References: <788af57d-750d-418d-94bb-75c6557e36a9@g4g2000pbn.googlegroups.com> <3f8db781-fd78-4505-837d-1811c0f9b96f@googlegroups.com> <18bqgllh2jdwg$.upj6crleq9nv$.dlg@40tude.net> <3u95tkqb1l8t$.t7lzt049tvq8.dlg@40tude.net> Reply-To: mailbox@dmitry-kazakov.de NNTP-Posting-Host: 9A8bJrx4NhDLcSmbrb6AdA.user.speranza.aioe.org Mime-Version: 1.0 X-Complaints-To: abuse@aioe.org User-Agent: 40tude_Dialog/2.0.15.1 X-Notice: Filtered by postfilter v. 0.8.2 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Date: 2012-07-07T10:22:06+02:00 List-Id: On Fri, 6 Jul 2012 18:47:22 -0500, Randy Brukardt wrote: > "Dmitry A. Kazakov" wrote in message > news:3u95tkqb1l8t$.t7lzt049tvq8.dlg@40tude.net... >> On Wed, 4 Jul 2012 20:33:32 -0500, Randy Brukardt wrote: > ... >>> This is distributed overhead, which programs would have to pay whether or >>> not they used any 2-d slices. It would make all array parameters more >>> expensive. >> >> By-value passed slices should impose no overhead. > > Sure. but they're not a general solution. I suppose it is for a great majority of people asking for this feature. E.g. those doing linear algebra stuff. > That is, they don't work for slices of arrays of by-reference types, Yes, but nD arrays of those are rare. One important exception could be arrays of controlled types used to implement fat pointers, e.g. handles. >>>> Slices should be first class, that would remove the burden of >>>> implementation from compiler writers. The rest is just same problematic as >>>> with referencing single array/container element. There is no big >>>> difference for one element or a set of elements. >>> >>> That's not really possible so long as slices are what C calls l-values. The >>> problem is passing slices as parameters and allowing assignments into >>> them. >> >> Why does this work for array elements then? > > (There is a "not" missing in what I wrote above.) > > It works for array elements only because they are contiguous and passing a > single address is sufficient to represent the slice, as it is for any array > objects. (Recall that we're talking about *constrained* array parameters > here.) That is why you could pass it copy-in/copy-out as you would with scalar array elements. Yes, it would be much work and likely many compiler bugs, but not impossible. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de