From: Stephen Leake on
stefan-lucks(a)see-the.signature writes:

> On Thu, 6 May 2010, Warren wrote:
>
>> I'm just being a typical lazy programmer (not always
>> wanting to lookup the correct package prefix for
>> the To_String() function to use).
>
> How about overloading the &-operator:
>
> function "&"(S: String; Item: T) return String;
>
> if X is of type T and you "use type T", you can replace the expression
>
> T'Image(X)
>
> by
>
> "" & X
>
> If your T'Image(X) is part of a larger string expression, overloading &
> appears to be very convenient (for the "typical lazy programmer", as you
> put it):
>
> Ada.Text_IO.Put_Line("The first result is " & X &
> " the second result is " & Y & ".");

+1

--
-- Stephe
From: Stephen Leake on
"Yannick Duchêne (Hibou57)" <yannick_duchene(a)yahoo.fr> writes:

> 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 ?

Yes, but I don't see why that matters.

Sometimes I need Image to be dispatching; then it has to be in the main
package, not a child.

--
-- Stephe
From: Randy Brukardt on
"Jeffrey R. Carter" <spam.jrcarter.not(a)spam.acm.org> wrote in message
news:hs23ks$8vq$2(a)tornado.tornevall.net...
> Randy Brukardt wrote:
>>
>> If I actually used a signature line, I think I'd be using that one!!
>
> Thanks. Why not use a signature line?

I'm an antique: I still type all of my message (other than part I'm replying
to) by hand. That includes the signature. "Randy." is easy enough to type; a
complex signature isn't.

Randy.


From: Randy Brukardt on
"Yannick Duch�ne (Hibou57)" <yannick_duchene(a)yahoo.fr> wrote in message
news:op.vccvt1ybxmjfy8(a)garhos...
Le Fri, 07 May 2010 23:27:55 +0200, Randy Brukardt <randy(a)rrsoftware.com>
a �crit:
....
>> It doesn't work very well, either, if you are outputting to a message box
>> or
>> to a log manager: in both cases the entire message string has to be
>> passed
>> at once. (That's the case in virtually all of my newer programs.) Not
>> many
>> real programs do much output to Standard Output.
>
>There are alternatives, and here are two.
>
>The first one : the log manager could have an open/close logic to output a
>log line.

That's what mine does, but its purpose is to serialize logging from all of
the tasks in the system, all of which are doing their own thing without any
special synchronization. If we tried to write parts of each message, we'd
get a bunch of interspersed parts (or we'd have to have a very complex
system of saving the parts inside the manager until the entire line is
available). The other purpose is to make the logs available for inspection
at any time (the programs in question are Windows services, so they run for
months at a time); that's why they aren't just held open all the time.

....
> Another alternative I have used some months ago, was to use an abstraction
> of what a text is : I was passing procedure writing text instead of
> strings (to be exact, this was not access to procedures, this was tagged
> types with a single method).

Interestingly, that's how the tasks find out which particular log they are
supposed to be writing to: I pass an access-to-logging-routine.

It's also a way to do I/O from Pure/Preelaborated packages.

But you need two such routines if you plan to allow separating basic writing
and ending of a line: New_Line is not a character, you know! (At least not
if you are writing a portable Ada program, and want to work on many
different targets.)

> I'm not to say this is an easy suitable for beginners (as we were also
> talking about ease of access for beginners), I'm just exposing this as
> example alternatives to the one-string-bulk way.

But none work very well, because you still have to identify the end of the
line. Either you have to designate a magic character for that purpose,
leaving Ada far behind (and also requiring scanning each string as well), or
you need multiple routines (as Text_IO does). Whole line at a time is
easiest, IMHO, and matches what you want to do enough of the time that there
isn't much advantage to doing anything else. YMMV.

Randy.


From: Randy Brukardt on
"Simon Wright" <simon(a)pushface.org> wrote in message
news:m2k4rfjruq.fsf(a)pushface.org...
> Robert A Duff <bobduff(a)shell01.TheWorld.com> writes:
>
>> Now why isn't this:
>>
>> Put_Line ((Finish_Time - Start_Time)'Img);
>>
>> legal?
>
> Can the compiler be expected to work out what that function "-" is?

Well, the prefix of an attribute is almost always an "any type" context. (It
surely is for this attribute). So the answer depends on whether Start_Time
and Finish_Time and "-" are overloaded. If these are two objects, probably
there is only one matching "-". If they are overloaded functions, all bets
are off. So this probably would work *some* of the time. Hard to say if it
is worth it to make it work.

Randy.