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.190.104 with SMTP id gp8mr8088188pbc.4.1341452020113; Wed, 04 Jul 2012 18:33:40 -0700 (PDT) MIME-Version: 1.0 Path: l9ni10941pbj.0!nntp.google.com!news2.google.com!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: Wed, 4 Jul 2012 20:33:32 -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> NNTP-Posting-Host: static-69-95-181-76.mad.choiceone.net X-Trace: munin.nbi.dk 1341452017 31826 69.95.181.76 (5 Jul 2012 01:33:37 GMT) X-Complaints-To: news@jacob-sparre.dk NNTP-Posting-Date: Thu, 5 Jul 2012 01:33:37 +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-04T20:33:32-05:00 List-Id: "Dmitry A. Kazakov" wrote in message news:18bqgllh2jdwg$.upj6crleq9nv$.dlg@40tude.net... > On Mon, 2 Jul 2012 23:22:46 -0500, Randy Brukardt wrote: > >> All which means that the result would be too complex to use for most >> people. > > Too complex compared to writing it manually? Yes. If the meaning of the syntax is not immediately obvious, you run a significant risk of reading/writing something other than what you really want. I can think of at least two meanings for A(2..3, 4..4), and that is where the problem arises. >> Not to mention the extra overhead. > > Again, compared to what? Compared to a language without 2-d slices. 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. Distributed overhead is only acceptable in cases where there is a clear and important value to the new feature. The overhead for the slicing feature itself isn't a problem, it's the overhead for all of the programs that don't use the feature and don't care about the feature that is the problem. > 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. (Just allowing them to be read is not much of a problem, at least for by-copy types.) > The language should support that for all container types, array is one. > Ada > 2012 has a kludge for doing that by reference. There should be another for > doing that using value semantics (copy-out, copy-in). 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'd rather spend my time getting exception contracts to work. Randy.