From: Robert A Duff on
"J-P. Rosen" <rosen(a)adalog.fr> writes:

> Robert A Duff a �crit :
>> 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.
>
> 'Image is just for quick, debug-like output.

So that's why it's broken?!

I'm imagining the Ada 83 design team saying, "This feature is
only for quick, debug-like output, so let's make it do
something annoying, so folks won't be able to use it
for serious work, MWAHAHAH." ;-)
Sorry, I don't buy that -- I think they just made a mistake.

And it's too late to fix it.

>...If you want nice formatted
> output, by all means use the IO packages, that's what they are for.

I don't want nice formatted output. I want the human-readable
string image of the number, and for 123, that's "123",
not " 123". In other words, I want:

Put_Line (Error_Count'Image (Num_Errors) & " errors detected.");

to print:

123 errors detected.

All this talk about formatting came from folks asking
why does 'Image produce an annoying blank, and the
proposed answer was "for columnar formatted output",
and the response is "no, that doesn't explain it,
because an annoying blank doesn't do columnar output".

- Bob
From: Robert A Duff on
"Randy Brukardt" <randy(a)rrsoftware.com> writes:

> I actually don't buy the need for the Assert pragma in the first place: such
> checks are rarely expensive and thus should simply be part of the code
> always.

If they're not expensive, then you're not using it enough. ;-)

Also, the other advantage of pragma Assert over an Assert
procedure is that you can put the pragma in declarative parts
and package specs.

>... (And the ones that are expensive need a lot more control than simply
> on or off: Janus/Ada uses trace switches that can be controlled on a
> per-unit basis.)

Sorry, I don't buy that sort of argument in general: If you want to
do (simple) X, you probably also want (complicated) Y, so we're
not going to allow X.

- Bob
From: Georg Bauhaus on
On 07.05.10 14:21, Robert A Duff wrote:
> "J-P. Rosen" <rosen(a)adalog.fr> writes:

>>> I don't get it. 'Image isn't particularly helpful in producing
>>> columnar output.
>>
>> 'Image is just for quick, debug-like output.
>
> So that's why it's broken?!
>
> I'm imagining the Ada 83 design team saying, "This feature is
> only for quick, debug-like output, so let's make it do
> something annoying, so folks won't be able to use it
> for serious work, MWAHAHAH." ;-)
> Sorry, I don't buy that -- I think they just made a mistake.

With 'Width given, and with 'Value reading "+123" like
" 123", WRT to what is there a mistake?
Would there be a discussion at all if "+123" had
been chosen as the result of 'Image (123)?


> I don't want nice formatted output. I want the human-readable
> string image of the number, and for 123, that's "123",
> not " 123".

"123" to be the only representation ever wanted for 123 seems
like a far reaching assumption to me. Others may want "+123" for
positive, "#123" for negative etc. And "123" just *happens* to
be what one might want in this or that case.

I imagine that writing two statements for "just a number
and a string" makes some programmers feel annoyed because two
statements instead of one---though involving two functions---seems
verbose.

Put (Num_Errors);
Put_Line (" errors detected.");

"You never do such complicated things in Javascript's alert()"...
A way out:

Put (Num_Errors); Put_Line (" errors detected.");

From: Robert A Duff on
Georg Bauhaus <rm.dash-bauhaus(a)futureapps.de> writes:

> With 'Width given, and with 'Value reading "+123" like
> " 123", WRT to what is there a mistake?

I don't think I've ever used 'Width in my entire life.
Anyway, 'Width has little to do with 'Image,
since 'Image doesn't have a Width parameter.

And 'Value also accepts " 123 ",
which is not an argument for putting in a whole
bunch of blanks.

> Would there be a discussion at all if "+123" had
> been chosen as the result of 'Image (123)?

Then there'd be a different discussion, about the
"annoying plus sign". ;-)

Num_Errors, like most integer subtypes, doesn't have
any negative numbers. Putting in a "+" sign makes
even less sense than putting in a blank.

>> I don't want nice formatted output. I want the human-readable
>> string image of the number, and for 123, that's "123",
>> not " 123".
>
> "123" to be the only representation ever wanted for 123 seems
> like a far reaching assumption to me. Others may want "+123" for
> positive, "#123" for negative etc. And "123" just *happens* to
> be what one might want in this or that case.

"123" is by far the most common representation wanted.
And if you want to stick in a blank or a "+",
it's easy to concatenate that, whereas removing such
junk is verbose and error prone.

Sometimes, you want ", and" after the number -- but
you don't want 'Image to stick that in for you!

> I imagine that writing two statements for "just a number
> and a string" makes some programmers feel annoyed because two
> statements instead of one---though involving two functions---seems
> verbose.
>
> Put (Num_Errors);
> Put_Line (" errors detected.");

The problem with the Text_IO design is that it mixes
I/O with formatting. It would be cleaner to separate these.

It would also be cleaner to separate I from O, but that's
another story.

Anyway, the question was, "Why on Earth would they put
in that annoying blank?" As far as I can tell, the
correct answer is "No reason -- they did it by mistake."
You can't answer the question by pointing out various
workarounds.

And teaching beginners how to instantiate generics,
when there's a simple 'Image feature, is not a good idea.

- Bob
From: Yannick Duchêne (Hibou57) on
Le Fri, 07 May 2010 12:15:11 +0200, Stephen Leake
<stephen_leake(a)stephe-leake.org> a écrit:
>> I always declare I/O/formatting stuff in a child package.
>
> Me, to. And the childe package is named Images.
Are you talking about packages defining multiple types ?

I had to ask this question to be sure, as I can't so much easily figure
out what's the layout of what you are talking about (although this is
probably simple).

--
No-no, this isn't an oops ...or I hope (TM) - Don't blame me... I'm just
not lucky