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.132.69 with SMTP id os5mr3631011pbb.6.1330556806718; Wed, 29 Feb 2012 15:06:46 -0800 (PST) Path: h9ni24539pbe.0!nntp.google.com!news2.google.com!news.glorb.com!solaris.cc.vt.edu!news.vt.edu!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Array Help? Date: Wed, 29 Feb 2012 18:06:46 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <10615783-d4a9-4cbd-8971-53ba1100d6a0@b18g2000vbz.googlegroups.com> <17412419.40.1330534213855.JavaMail.geo-discussion-forums@vbva11> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 X-Trace: pcls6.std.com 1330556806 31571 192.74.137.71 (29 Feb 2012 23:06:46 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Wed, 29 Feb 2012 23:06:46 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:GY1htUo3gpG4uGryt7KsAwQz7SU= Content-Type: text/plain; charset=us-ascii Date: 2012-02-29T18:06:46-05:00 List-Id: stefan-lucks@see-the.signature writes: > On Wed, 29 Feb 2012, Robert A Duff wrote: > >> Anyway, slices aren't really all that useful -- for many array types, >> you don't need them at all. And slices as l-values, as in your >> example, are quite rare, because you really want to be able to >> change the length of the slice, if you want to change it at all. > > Not quite. I quite frequently use something like > > X := X(X'Last) & (X'First .. X'Last-1) > > and > > First := X'First; > while First < X'Last and then X(First) = ' ' loop > First := First + 1; > end loop; > return X(First .. X'Last); > > and similar constructs, where array slicing is a highly useful language > feature. Mildly useful, I'd say. If you didn't have slices, you'd have to write a few lines of code instead of the above -- an extra loop. That's a purely local change. No big deal. Contrast that with features like packages, private types, user-defined integer types, etc, the lack of which would damage the entire structure of your program. 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. 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. > 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. - Bob