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,FREEMAIL_FROM autolearn=unavailable autolearn_force=no version=3.4.4 X-Received: by 10.70.35.34 with SMTP id e2mr3060154pdj.6.1433496404688; Fri, 05 Jun 2015 02:26:44 -0700 (PDT) X-Received: by 10.140.48.11 with SMTP id n11mr22406qga.35.1433496404267; Fri, 05 Jun 2015 02:26:44 -0700 (PDT) Path: buffer1.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!h15no631304igd.0!news-out.google.com!4ni200qgh.1!nntp.google.com!z60no400578qgd.1!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail Newsgroups: comp.lang.ada Date: Fri, 5 Jun 2015 02:26:44 -0700 (PDT) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=20.133.0.13; posting-account=YRfoYAoAAADhSEO2nLYx10QUUvp8akYl NNTP-Posting-Host: 20.133.0.13 References: <0b23f4af-9a55-4d1d-be90-f74b316a95cf@googlegroups.com> User-Agent: G2/1.0 MIME-Version: 1.0 Message-ID: <6abd0040-d476-44f5-ad55-73494c2eb8b8@googlegroups.com> Subject: Re: How to get this space away? From: Stephen Davies Injection-Date: Fri, 05 Jun 2015 09:26:44 +0000 Content-Type: text/plain; charset=ISO-8859-1 Xref: number.nntp.giganews.com comp.lang.ada:193498 Date: 2015-06-05T02:26:44-07:00 List-Id: On Thursday, 4 June 2015 00:00:56 UTC+1, Randy Brukardt wrote: > "J-P. Rosen" wrote in message > > This dates back to Ada83. The initial idea was that a positive number > > and its opposite (negative) number should have the same number of > > characters. Forcing a '+' to all positive number would not have been > > pretty, so the design team chose to put a space for positive numbers > > (negative numbers just have an initial '-'). > > > > At first, it looked like a good idea, especially since 'Image was not > > intended to be used extensively, but just for debugging purposes. For > > IOs, people are supposed to use Text_IO, which provides all the desired > > formatting. In practice, it turned out to be a bad idea, and lots of > > programs have some functions to remove the initial space - and now, > > changing that would break all these programs. And the ARG is very picky > > about upward compatibility. > > "all these programs" should be "most of these programs". Programs using > Trim, as Jeff suggested, won't break. > > But my code does a lot of this: > > declare > Img : constant String := Natural'Image(Something); > begin > Log ("Something out of range; Something=" & Img(2..Img'Last)); > end; > > and that would break horribly if the space was removed. > > The upcoming Corrigendum adds Obj'Image (The GNAT 'Img is used so much that > it seems silly to not make it part of the standard); we spent a few minutes > discussing that leading space, but eventually we decided that taking it out > would be just as confusing (to experts) as leaving it in is (to novices). > > > The only possibility would be to define a new attribute. Small effort, > > small value. > > Right, and the effort (in the Standard and especially for implementers) > probably outweights the value. I think that probably almost every Ada programmer has had to work around the leading space from 'Image at some point. Would it really be that hard to add one of the following to either overload or replace it, respectively? function S'Image (Arg : S'Base; Width : Natural) return String function S'Image (Arg : S'Base; Width : Integer := -1) return String