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,32d9aa9d79729b31 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.68.241.162 with SMTP id wj2mr14696876pbc.2.1341618450850; Fri, 06 Jul 2012 16:47:30 -0700 (PDT) MIME-Version: 1.0 Path: l9ni11017pbj.0!nntp.google.com!news2.google.com!feed-C.news.volia.net!volia.net!news2.volia.net!feed-A.news.volia.net!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: Any easy/build-in construct to extract submatrices from larger matrix? Date: Fri, 6 Jul 2012 18:47:22 -0500 Organization: Jacob Sparre Andersen Research & Innovation Message-ID: 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> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1341618448 12583 69.95.181.76 (6 Jul 2012 23:47:28 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Fri, 6 Jul 2012 23:47:28 +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-07-06T18:47:22-05:00 List-Id: "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. That is, they don't work for slices of arrays of by-reference types, which a compiler would have to support. Since this is not an important feature for our customers, we would not want to support more than one implementation of it. And even if we did, there would still be distributed overhead in any parameter type that could not be passed by copy (which is most of them, if new types are always controlled, as I recommend in most cases). >>> 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.) ... ... >> Value semantics only works for a small subset of types (for most >> compilers, >> that subset is elementary types). Moreover, Ada has many types for which >> value semantics is not allowed (immutably limited types and tagged types >> are >> the best known). So this would be a feature of fairly limited value. > > I don't see big problem here. Arrays of referential elements are most > likely internally are array of pointers. Slices of such arrays are again > arrays of pointers. There is nothing difficult about that, except that > usual problems that a reference shall not outlive the object. That's not how our compiler handles by-reference types. They live like other objects in place, but are always *passed* by reference (there is no requirement to *allocate* them by reference). There are some cases where we use implicit pointers (such as in shared generics), but that's unusual for Ada compilers. I don't think GNAT ever uses them. Randy.