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,2ac407a2a34565a9 X-Google-NewGroupId: yes X-Google-Attributes: gida07f3367d7,domainid0,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Received: by 10.42.134.134 with SMTP id l6mr893397ict.3.1330544347879; Wed, 29 Feb 2012 11:39:07 -0800 (PST) Path: h9ni23967pbe.0!nntp.google.com!news1.google.com!goblin1!goblin.stu.neva.ru!news.osn.de!diablo2.news.osn.de!news.belwue.de!news.uni-stuttgart.de!news-2.dfn.de!news.dfn.de!news.uni-weimar.de!not-for-mail From: stefan-lucks@see-the.signature Newsgroups: comp.lang.ada Subject: Re: Array Help? Date: Wed, 29 Feb 2012 20:45:07 +0100 Organization: Bauhaus-Universitaet Weimar Message-ID: References: <10615783-d4a9-4cbd-8971-53ba1100d6a0@b18g2000vbz.googlegroups.com> <17412419.40.1330534213855.JavaMail.geo-discussion-forums@vbva11> Reply-To: stefan-lucks@see-the.signature NNTP-Posting-Host: medsec1.medien.uni-weimar.de Mime-Version: 1.0 X-Trace: tigger.scc.uni-weimar.de 1330544347 25837 141.54.178.228 (29 Feb 2012 19:39:07 GMT) X-Complaints-To: news@tigger.scc.uni-weimar.de NNTP-Posting-Date: Wed, 29 Feb 2012 19:39:07 +0000 (UTC) X-X-Sender: lucks@medsec1.medien.uni-weimar.de In-Reply-To: Content-Type: TEXT/PLAIN; charset=US-ASCII Date: 2012-02-29T20:45:07+01:00 List-Id: 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. 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 -- inside Sort, Items'First=1 and Item'Last = Items'Length -- regardless of the index type of the actual parameter begin ... end Sort; and later call the same Sort procedure Sort(X); Sort(Y); Sort(Z); for any one-dimensional array of type T, e.g., X: array (Positive range 3 .. 13) of T; Y: array (range 31 .. 3343) of T; type Month_Names is (January, [...] December); Z: array (Month_Names) of T; -- ---- Stefan.Lucks (at) uni-weimar.de, University of Weimar, Germany ---- ------ I love the taste of Cryptanalysis in the morning! ------