comp.lang.ada
 help / color / mirror / Atom feed
From: Stephen Davies <joviangm@gmail.com>
Subject: Re: How to get this space away?
Date: Fri, 5 Jun 2015 02:26:44 -0700 (PDT)
Date: 2015-06-05T02:26:44-07:00	[thread overview]
Message-ID: <6abd0040-d476-44f5-ad55-73494c2eb8b8@googlegroups.com> (raw)
In-Reply-To: <mko0v6$2b5$1@loke.gir.dk>

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


  reply	other threads:[~2015-06-05  9:26 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-02 20:32 How to get this space away? Laurent
2015-06-02 20:53 ` Simon Wright
2015-06-03 18:59   ` Laurent
2015-06-03 19:30     ` Simon Wright
2015-06-02 22:28 ` Jeffrey R. Carter
2015-06-03 19:07   ` Laurent
2015-06-03 20:50     ` J-P. Rosen
2015-06-03 23:00       ` Randy Brukardt
2015-06-05  9:26         ` Stephen Davies [this message]
2015-06-08 12:33         ` Brad Moore
2015-06-08 19:47           ` Randy Brukardt
2015-06-08 20:25             ` Jeffrey R. Carter
2015-06-09 14:38               ` Brad Moore
2015-06-04  9:37       ` Georg Bauhaus
2015-06-04 12:32         ` Dmitry A. Kazakov
2015-06-05 13:02       ` Laurent
2015-06-06  0:02         ` Dennis Lee Bieber
2015-06-03  7:28 ` Dmitry A. Kazakov
2015-06-03 19:19   ` Laurent
2015-06-08 22:43 ` wowwomenonwheels205
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox