Re: Real Time IO routines
- From: anon@xxxxxxxx (anon)
- Date: Sat, 27 Oct 2007 20:15:15 GMT
Ada Purist never and I mean NEVER uses IMAGE attribute, in the body of
a program. They create a package or sub-package that performs the IO
functions with the use of the IMAGE attribute.
IMAGE attribute is the last thing a programmer should use. to print a value.
It is normally use for DEBUGGING ONLY! A programmer should always create
a routine or better yet a package that uses an algorithm to prints the value
without the use of attributes.
Mostly programs that are created by newbees use IMAGE attribute.
And as for my code! It answer the person question without adding extra
code that might confuse him. Plus, the "Ada.Real_Time" package uses:
type Time is new Duration;
which is in private section. So I know what to convert the value to.
In <ddn82trtef34$.n1ulcxn4se96.dlg@xxxxxxxxxx>, "Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx> writes:
On Sat, 27 Oct 2007 08:56:42 GMT, anon wrote:
function To_Duration is new Ada.Unchecked_Conversion( Time, Duration ) ;
That is a bad idea. You don't know what is the internal representation of
Time. The intended effect can be achieved legally:
with Ada.Real_Time; use Ada.Real_Time;
with Ada.Text_IO; use Ada.Text_IO;
procedure Test is
function Image (T : Time) return String is
Seconds : Seconds_Count;
Fraction : Time_Span;
begin
Split (T, Seconds, Fraction);
declare
After : constant String :=
Duration'Image (To_Duration (Fraction));
begin
return Seconds_Count'Image (Seconds) & After (2..After'Last);
end;
end Image;
begin
delay 0.5;
Put_Line (Image (Clock) & "s since the epoch");
delay 0.5;
Put_Line (Image (Clock) & "s since the epoch");
end Test;
--------------------
However it is quite useless to output absolute time values involving an
unknown epoch. Unfortunately there is no portable way I know of to convert
Real_Time.Time to UTC.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.
- Follow-Ups:
- Re: Real Time IO routines
- From: andrew
- Re: Real Time IO routines
- From: Adam Beneschan
- Re: Real Time IO routines
- From: Jeffrey Creem
- Re: Real Time IO routines
- From: Simon Wright
- Re: Real Time IO routines
- From: Dmitry A. Kazakov
- Re: Real Time IO routines
- References:
- Real Time IO routines
- From: andrew
- Re: Real Time IO routines
- From: anon
- Re: Real Time IO routines
- From: Dmitry A. Kazakov
- Real Time IO routines
- Prev by Date: Re: Real Time IO routines
- Next by Date: Re: Real Time IO routines
- Previous by thread: Re: Real Time IO routines
- Next by thread: Re: Real Time IO routines
- Index(es):
Relevant Pages
|