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: a07f3367d7,bf03d731a6ef511f X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news4.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!panix!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Copying rows in a two dimensional array. Date: Tue, 09 Feb 2010 09:45:26 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <12ezqn0wq0lmm$.s7nr5aueiwa4$.dlg@40tude.net> <3e1a4234-95ef-4e77-a87d-1bc6e560fe7f@z10g2000prh.googlegroups.com> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: pcls6.std.com 1265726716 20601 192.74.137.71 (9 Feb 2010 14:45:16 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Tue, 9 Feb 2010 14:45:16 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:nE4kEH06ksj2PjEDpsh75HE0Lbk= Xref: g2news1.google.com comp.lang.ada:9035 Date: 2010-02-09T09:45:26-05:00 List-Id: Adam Beneschan writes: > On Feb 8, 1:20�pm, Robert A Duff wrote: >> And anyway, slices as L-values don't really work: >> >> � � X : String := "abc"; >> >> � � X (2..2) := "xxx"; >> >> One might expect X = "axxxc", > > One *what*?? One Perl programmer??? > > Really, I don't expect that anyone who understands Ada is going to get > this wrong. Yes, of course. My point is just that if you want to replace a slice of a string with another string, you can't do it, unless they happen to be the same size. I agree most Ada programmers understand that -- and if they don't, they'll find out pretty quickly. Or you can do a lot of horsing around with unbounded strings. And there, you don't get any special slice syntax, just subprograms. I really hate the fact that you don't get normal string syntax for unbounded strings, but if I had to choose which such syntax I want the most, I'd choose string literals and indexing long before I'd choose slices. >...Programmers who haven't yet learned the language may not > understand it, but that's probably true of *any* feature of the > language, except perhaps for this: > > procedure Main_Program is > begin > null; > end Main_Program; > > Like most of the other posters here, I find slices very useful. Yeah, everybody in this thread is singing the praises of slices. But nobody's taken my challenge: write down several features of Ada that you'd rather do without than slices. In other words, fill in the blank: I'd rather do without ________ than do without slices. I can think of some: Entry families. Line/column counting in Text_IO. But you won't find me putting "packages" or "case statements" or "parameter passing" in that blank! My point is: the benefit of slices (over plain old procedure calls) has to be relative to other features. Just saying "slices are useful" doesn't contradict anything I said -- I agree they're useful. >...Also, > I don't have a particular problem using them, on both sides of ":=". > I don't think I get them wrong any more than I get anything else > wrong. Well, what started this was my claim that all strings, including slices, ought to start at 1. I've seen huge numbers of bugs where this was incorrectly assumed. And it's nasty, because the vast majority of strings DO start at one, so you don't notice the bug right away. You notice it a year later when somebody passes a slice to a procedure that always worked before. - Bob