Prev: Question about default discriminants and mutable objects.
Next: Why is not Stream_Access defined Ada.Streams ?
From: Robert A Duff on 6 May 2010 16:22 Warren <ve3wwg(a)gmail.com> writes: > I agree that it is indeed clumsier. It's just that > I tend to use it a lot in debug output, rather than > chasing down the package prefix for the To_String() > function. I know I can always get away with: > > Put_Line("The value V=" & T'Image(V)); I don't understand that. You need to chase down the package in which T is declared, which is the same package in which To_String (or better, Image) is declared. Or use use clauses. - Bob
From: Yannick Duchêne (Hibou57) on 6 May 2010 16:56 Le Thu, 06 May 2010 22:19:15 +0200, Robert A Duff <bobduff(a)shell01.theworld.com> a écrit: > The leading blank produced by T'Image is indeed annoying! > What were they thinking?! Never mind, that's been discussed > to death. It's not a huge problem, but it's one of the > first things new Ada programmers notice, and it's a real > turn-off. > > - Bob I'm sometime lazy too, so I did not check the reference about it, however, I can say today I used 'Image on a "mod type", and there was no heading blank, while that's true I have one with with kinds of Integer or Natural. What there were thinking about ? Perhaps proper display when different numbers are displayed on a column and some are Integer, others Natural. By the way, Natural is a subset of Integer, so these are numbers which are always positive, not numbers without a sign. A quick work around (for more serious stuff, it's good any way to write a custom Image function) : one typically wish to output numbers preceded by a text or label, so just don't put any trailing blank on the latter. -- No-no, this isn't an oops ...or I hope (TM) - Don't blame me... I'm just not lucky
From: Robert A Duff on 6 May 2010 17:11 "Yannick Duch�ne (Hibou57)" <yannick_duchene(a)yahoo.fr> writes: > What there were thinking about ? Perhaps proper display when different > numbers are displayed on a column and some are Integer, others > Natural. But for "columns" you want something like: 1 -3 123 -123 But 'Image gives you: 1 -3 123 -123 I don't get it. 'Image isn't particularly helpful in producing columnar output. >... By the way, Natural is a subset of Integer, so these are > numbers which are always positive, not numbers without a sign. Sure, but the vast majority of integers I want to do 'Image on are nonnegative. For example, if you print the length of a String, there is zero chance that it's negative, so leaving an extra blank in case it might be negative makes no sense. - Bob
From: Dmitry A. Kazakov on 6 May 2010 17:20 On Thu, 06 May 2010 22:56:51 +0200, Yannick Duch�ne (Hibou57) wrote: > Le Thu, 06 May 2010 22:19:15 +0200, Robert A Duff > <bobduff(a)shell01.theworld.com> a �crit: > >> The leading blank produced by T'Image is indeed annoying! >> What were they thinking?! Never mind, that's been discussed >> to death. It's not a huge problem, but it's one of the >> first things new Ada programmers notice, and it's a real >> turn-off. >> > I'm sometime lazy too, so I did not check the reference about it, however, > I can say today I used 'Image on a "mod type", and there was no heading > blank, while that's true I have one with with kinds of Integer or Natural. Not always. Blank is actually '+'. Integer'Image (-1) is "-1", no blanks. Integer'Image (1) is " 1". (In almost unlikely case if you printed integers in columns and these integers were of same length, you would get columns aligned! (:-)) > What there were thinking about ? punched cards? (:-)) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de
From: Dmitry A. Kazakov on 6 May 2010 17:25
On Thu, 06 May 2010 16:22:03 -0400, Robert A Duff wrote: > Warren <ve3wwg(a)gmail.com> writes: > >> I agree that it is indeed clumsier. It's just that >> I tend to use it a lot in debug output, rather than >> chasing down the package prefix for the To_String() >> function. I know I can always get away with: >> >> Put_Line("The value V=" & T'Image(V)); > > I don't understand that. You need to chase down the package > in which T is declared, which is the same package in which > To_String (or better, Image) is declared. I always declare I/O/formatting stuff in a child package. So, T'Image has some minor advantages. (The argument would really work if it were V'Image or V.Image) -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de |