comp.lang.ada
 help / color / mirror / Atom feed
* Real Time IO routines
@ 2007-10-26 14:58 andrew
  2007-10-26 16:43 ` Anh Vo
                   ` (2 more replies)
  0 siblings, 3 replies; 56+ messages in thread
From: andrew @ 2007-10-26 14:58 UTC (permalink / raw)


Hello,

Is there a put or put_line procedure to output the value of variables
declared as the Time type defined in the Real_Time package?




^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-26 14:58 Real Time IO routines andrew
@ 2007-10-26 16:43 ` Anh Vo
  2007-10-26 16:53   ` andrew
  2007-10-26 17:12 ` Ed Falis
  2007-10-27  8:56 ` anon
  2 siblings, 1 reply; 56+ messages in thread
From: Anh Vo @ 2007-10-26 16:43 UTC (permalink / raw)


On Oct 26, 7:58 am, andrew <andrew.carr...@okstate.edu> wrote:
> Is there a put or put_line procedure to output the value of variables
> declared as the Time type defined in the Real_Time package?

May I ask for purpose you would like to achieve?

AV




^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-26 16:43 ` Anh Vo
@ 2007-10-26 16:53   ` andrew
  2007-10-26 17:04     ` Anh Vo
  0 siblings, 1 reply; 56+ messages in thread
From: andrew @ 2007-10-26 16:53 UTC (permalink / raw)


On Oct 26, 11:43 am, Anh Vo <anhvofrc...@gmail.com> wrote:
> On Oct 26, 7:58 am, andrew <andrew.carr...@okstate.edu> wrote:
>
> > Is there a put or put_line procedure to output the value of variables
> > declared as the Time type defined in the Real_Time package?
>
> May I ask for purpose you would like to achieve?
>
> AV

For the purpose of collecting statistical data about the performance
of an algorithm.




^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-26 16:53   ` andrew
@ 2007-10-26 17:04     ` Anh Vo
  2007-10-26 17:21       ` andrew
  0 siblings, 1 reply; 56+ messages in thread
From: Anh Vo @ 2007-10-26 17:04 UTC (permalink / raw)


On Oct 26, 9:53 am, andrew <andrew.carr...@okstate.edu> wrote:
> > On Oct 26, 7:58 am, andrew <andrew.carr...@okstate.edu> wrote:
>
> > > Is there a put or put_line procedure to output the value of variables
> > > declared as the Time type defined in the Real_Time package?
>
> > May I ask for purpose you would like to achieve?
>
> For the purpose of collecting statistical data about the performance
> of an algorithm.

Use function To_Duration (...) to convert Time to Duration. Then,
apply attribute Duration'Image (To_Duration(...)) to obtain your
number. I think you can take it from here.

AV





^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-26 14:58 Real Time IO routines andrew
  2007-10-26 16:43 ` Anh Vo
@ 2007-10-26 17:12 ` Ed Falis
  2007-10-27  8:56 ` anon
  2 siblings, 0 replies; 56+ messages in thread
From: Ed Falis @ 2007-10-26 17:12 UTC (permalink / raw)


On Fri, 26 Oct 2007 10:58:59 -0400, andrew <andrew.carroll@okstate.edu>  
wrote:

> Hello,
>
> Is there a put or put_line procedure to output the value of variables
> declared as the Time type defined in the Real_Time package?
>

If you're using Ada 2005 (eg an appropriate version of GNAT),  
Ada.Calendar.Formatting provides an Image routine that gives a string  
representation of Time.  This can then be used with Text_IO.



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-26 17:04     ` Anh Vo
@ 2007-10-26 17:21       ` andrew
  2007-10-26 18:31         ` Anh Vo
  2007-10-26 18:36         ` Ludovic Brenta
  0 siblings, 2 replies; 56+ messages in thread
From: andrew @ 2007-10-26 17:21 UTC (permalink / raw)


On Oct 26, 12:04 pm, Anh Vo <anhvofrc...@gmail.com> wrote:
> On Oct 26, 9:53 am, andrew <andrew.carr...@okstate.edu> wrote:
>
> > > On Oct 26, 7:58 am, andrew <andrew.carr...@okstate.edu> wrote:
>
> > > > Is there a put or put_line procedure to output the value of variables
> > > > declared as the Time type defined in the Real_Time package?
>
> > > May I ask for purpose you would like to achieve?
>
> > For the purpose of collecting statistical data about the performance
> > of an algorithm.
>
> Use function To_Duration (...) to convert Time to Duration. Then,
> apply attribute Duration'Image (To_Duration(...)) to obtain your
> number. I think you can take it from here.
>
> AV

Great!  I'll play around with that.  In the mean time, Time_Unit is
defined as a constant := 10#1.0#E-9, is Time_Unit then a "real
literal"?  How can I convert a "real literal" to a scalar type (maybe
that's a contradiction?)?

Thanks




^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-26 17:21       ` andrew
@ 2007-10-26 18:31         ` Anh Vo
  2007-10-26 18:36         ` Ludovic Brenta
  1 sibling, 0 replies; 56+ messages in thread
From: Anh Vo @ 2007-10-26 18:31 UTC (permalink / raw)


On Oct 26, 10:21 am, andrew <andrew.carr...@okstate.edu> wrote:
> Great!  I'll play around with that.  In the mean time, Time_Unit is
> defined as a constant := 10#1.0#E-9, is Time_Unit then a "real
> literal"?  How can I convert a "real literal" to a scalar type (maybe
> that's a contradiction?)?

If you use Real_Time.Time type for your metric calculation, what is
the relationship between Time_Unit and Time type? Why is it necessary?

AV




^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-26 17:21       ` andrew
  2007-10-26 18:31         ` Anh Vo
@ 2007-10-26 18:36         ` Ludovic Brenta
  2007-10-26 20:00           ` andrew
  1 sibling, 1 reply; 56+ messages in thread
From: Ludovic Brenta @ 2007-10-26 18:36 UTC (permalink / raw)


andrew writes:
> Time_Unit is defined as a constant := 10#1.0#E-9, is Time_Unit then
> a "real literal"?  How can I convert a "real literal" to a scalar
> type (maybe that's a contradiction?)?

Real literals are of the type universal_real which (a) is scalar and
(b) converts implicitly to any other floating-point type.  Does that
answer your question?

-- 
Ludovic Brenta.




^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-26 18:36         ` Ludovic Brenta
@ 2007-10-26 20:00           ` andrew
  2007-10-26 20:29             ` Ludovic Brenta
  2007-10-26 20:33             ` Dmitry A. Kazakov
  0 siblings, 2 replies; 56+ messages in thread
From: andrew @ 2007-10-26 20:00 UTC (permalink / raw)


On Oct 26, 1:36 pm, Ludovic Brenta <ludo...@ludovic-brenta.org> wrote:
> andrew writes:
> > Time_Unit is defined as a constant := 10#1.0#E-9, is Time_Unit then
> > a "real literal"?  How can I convert a "real literal" to a scalar
> > type (maybe that's a contradiction?)?
>
> Real literals are of the type universal_real which (a) is scalar and
> (b) converts implicitly to any other floating-point type.  Does that
> answer your question?
>
> --
> Ludovic Brenta.

To Ludovic:  Ahh, so if I had to define a universal_real I could
output it using something like integer'image(it)?

To AV:  I don't really know why it's necessary yet; sometimes my
subconcious mind works faster than my concious mind and I just have to
go with it.  I can say though that:

   --  Time and Time_Span are represented in 64-bit Duration value in
   --  in nanoseconds. For example, 1 second and 1 nanosecond is
   --  represented as the stored integer 1_000_000_001.

So if a duration is represented as the stored INTEGER ... then I could
maybe use integer'image(duration), maybe?

what does this mean:  type DURATION is delta implementation_defined
range implementation_defined;?
Is delta?  what's delta?





^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-26 20:00           ` andrew
@ 2007-10-26 20:29             ` Ludovic Brenta
  2007-10-26 20:46               ` Dmitry A. Kazakov
  2007-10-26 20:33             ` Dmitry A. Kazakov
  1 sibling, 1 reply; 56+ messages in thread
From: Ludovic Brenta @ 2007-10-26 20:29 UTC (permalink / raw)


andrew writes:
> On Oct 26, 1:36 pm, Ludovic Brenta <ludo...@ludovic-brenta.org> wrote:
>> andrew writes:
>> > Time_Unit is defined as a constant := 10#1.0#E-9, is Time_Unit then
>> > a "real literal"?  How can I convert a "real literal" to a scalar
>> > type (maybe that's a contradiction?)?
>>
>> Real literals are of the type universal_real which (a) is scalar and
>> (b) converts implicitly to any other floating-point type.  Does that
>> answer your question?
>>
>> --
>> Ludovic Brenta.
>
> To Ludovic:  Ahh, so if I had to define a universal_real I could
> output it using something like integer'image(it)?

No, because Integer is not a floating-point type.  You would use
Float'Image instead.  In light of what follows, I forgot to mention
that universal_real also converts to any fixed-point type implicitly.

> To AV:  I don't really know why it's necessary yet; sometimes my
> subconcious mind works faster than my concious mind and I just have to
> go with it.  I can say though that:
>
>    --  Time and Time_Span are represented in 64-bit Duration value in
>    --  in nanoseconds. For example, 1 second and 1 nanosecond is
>    --  represented as the stored integer 1_000_000_001.
>
> So if a duration is represented as the stored INTEGER ... then I could
> maybe use integer'image(duration), maybe?

No; Time and Time_Span are fixed-point types, not integer types.  You
should do:

Nanosecond : constant := 1.0E-9; -- there's your universal_real :)
type My_Fixed_Time is
  delta Nanosecond range 0.0 .. (2 ** 64 - 1) * Nanosecond;
for My_Fixed_Time'Size use 64;
function To_My_Fixed_Time is
  new Ada.Unchecked_Conversion (Source => Time; Target => My_Fixed_Time);

T : Time;
Image : constant String := My_Fixed_Time'Image (To_My_Fixed_Time (T));

(I just made that up; didn't try to compile it so caveat emptor).

> what does this mean:  type DURATION is delta implementation_defined
> range implementation_defined;?
> Is delta?  what's delta?

A fixed-point type.  See ARM 3.5.9.

-- 
Ludovic Brenta.



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-26 20:00           ` andrew
  2007-10-26 20:29             ` Ludovic Brenta
@ 2007-10-26 20:33             ` Dmitry A. Kazakov
  2007-10-26 21:14               ` andrew
  1 sibling, 1 reply; 56+ messages in thread
From: Dmitry A. Kazakov @ 2007-10-26 20:33 UTC (permalink / raw)


On Fri, 26 Oct 2007 13:00:13 -0700, andrew wrote:

> On Oct 26, 1:36 pm, Ludovic Brenta <ludo...@ludovic-brenta.org> wrote:
>> andrew writes:
>>> Time_Unit is defined as a constant := 10#1.0#E-9, is Time_Unit then
>>> a "real literal"?  How can I convert a "real literal" to a scalar
>>> type (maybe that's a contradiction?)?
>>
>> Real literals are of the type universal_real which (a) is scalar and
>> (b) converts implicitly to any other floating-point type.  Does that
>> answer your question?
> 
> To Ludovic:  Ahh, so if I had to define a universal_real I could
> output it using something like integer'image(it)?
> 
> To AV:  I don't really know why it's necessary yet; sometimes my
> subconcious mind works faster than my concious mind and I just have to
> go with it.  I can say though that:
> 
>    --  Time and Time_Span are represented in 64-bit Duration value in
>    --  in nanoseconds. For example, 1 second and 1 nanosecond is
>    --  represented as the stored integer 1_000_000_001.

You never know, that depends on the underlying hardware and OS. Even under
the same hardware/OS there exist multiple time sources with their own
precision and accuracy.

> So if a duration is represented as the stored INTEGER ... then I could
> maybe use integer'image(duration), maybe?
> 
> what does this mean:  type DURATION is delta implementation_defined
> range implementation_defined;?

It varies from platform to platform

> Is delta?  what's delta?

Precision of a fixed-point type. See ARM 3.5.9.

with Ada.Real_Time;  use Ada.Real_Time;
with Ada.Text_IO;    use Ada.Text_IO;

procedure Test is
   Start  : Time := Clock;
   Period : Duration;
   type Seconds is delta 0.000_001 range -1.0E10 .. 1.0E10;
      -- Microsecond precision type
begin
   delay 0.5;
   Period := To_Duration (Clock - Start);
   Put_Line ("Duration delta on this computer = " & Float'Image
(Duration'Delta));
   Put_Line (Duration'Image (Period) & "s");
   Put_Line (Integer'Image (Integer (Period * 1000.0)) & "ms");
      -- Be careful here, as it might overflow first in the multiplication
      -- and then in conversion to integer
   Put_Line (Float'Image (Float (Period)) & "s");
   Put_Line (Seconds'Image (Seconds (Period)) & "s");
end Test;

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-26 20:29             ` Ludovic Brenta
@ 2007-10-26 20:46               ` Dmitry A. Kazakov
  0 siblings, 0 replies; 56+ messages in thread
From: Dmitry A. Kazakov @ 2007-10-26 20:46 UTC (permalink / raw)


On Fri, 26 Oct 2007 22:29:58 +0200, Ludovic Brenta wrote:

> No; Time and Time_Span are fixed-point types, not integer types.

No, they are private types. Only Duration is a fixed-point type.

(Time_Span could be one, but it isn't. As for either Time cannot be an
arithmetic type because time is not a group: t1+t2 is meaningless, t1-t2 is
not an absolute time, but an interval.)

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-26 20:33             ` Dmitry A. Kazakov
@ 2007-10-26 21:14               ` andrew
  2007-10-26 21:54                 ` Anh Vo
                                   ` (3 more replies)
  0 siblings, 4 replies; 56+ messages in thread
From: andrew @ 2007-10-26 21:14 UTC (permalink / raw)


On Oct 26, 3:33 pm, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
wrote:
> On Fri, 26 Oct 2007 13:00:13 -0700, andrew wrote:
> > On Oct 26, 1:36 pm, Ludovic Brenta <ludo...@ludovic-brenta.org> wrote:
> >> andrew writes:
> >>> Time_Unit is defined as a constant := 10#1.0#E-9, is Time_Unit then
> >>> a "real literal"?  How can I convert a "real literal" to a scalar
> >>> type (maybe that's a contradiction?)?
>
> >> Real literals are of the type universal_real which (a) is scalar and
> >> (b) converts implicitly to any other floating-point type.  Does that
> >> answer your question?
>
> > To Ludovic:  Ahh, so if I had to define a universal_real I could
> > output it using something like integer'image(it)?
>
> > To AV:  I don't really know why it's necessary yet; sometimes my
> > subconcious mind works faster than my concious mind and I just have to
> > go with it.  I can say though that:
>
> >    --  Time and Time_Span are represented in 64-bit Duration value in
> >    --  in nanoseconds. For example, 1 second and 1 nanosecond is
> >    --  represented as the stored integer 1_000_000_001.
>
> You never know, that depends on the underlying hardware and OS. Even under
> the same hardware/OS there exist multiple time sources with their own
> precision and accuracy.
>
> > So if a duration is represented as the stored INTEGER ... then I could
> > maybe use integer'image(duration), maybe?
>
> > what does this mean:  type DURATION is delta implementation_defined
> > range implementation_defined;?
>
> It varies from platform to platform
>
> > Is delta?  what's delta?
>
> Precision of a fixed-point type. See ARM 3.5.9.
>
> with Ada.Real_Time;  use Ada.Real_Time;
> with Ada.Text_IO;    use Ada.Text_IO;
>
> procedure Test is
>    Start  : Time := Clock;
>    Period : Duration;
>    type Seconds is delta 0.000_001 range -1.0E10 .. 1.0E10;
>       -- Microsecond precision type
> begin
>    delay 0.5;
>    Period := To_Duration (Clock - Start);
>    Put_Line ("Duration delta on this computer = " & Float'Image
> (Duration'Delta));
>    Put_Line (Duration'Image (Period) & "s");
>    Put_Line (Integer'Image (Integer (Period * 1000.0)) & "ms");
>       -- Be careful here, as it might overflow first in the multiplication
>       -- and then in conversion to integer
>    Put_Line (Float'Image (Float (Period)) & "s");
>    Put_Line (Seconds'Image (Seconds (Period)) & "s");
> end Test;
>
> --
> Regards,
> Dmitry A. Kazakovhttp://www.dmitry-kazakov.de- Hide quoted text -
>
> - Show quoted text -

This is all great information; thank you all those that posted.

Something seems to be wrong though.  In my program I am basiclly
doing:

start := clock;
--I run my algorithm here
finish := clock;
ada.Text_IO.put_line("time = " & duration'image(to_duration(finish -
start)));

the output is always time = 0.000000000.  I know it had to take some
time because it takes about 10 seconds for the program to reach that
point in the code.  Overflow maybe?




^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-26 21:14               ` andrew
@ 2007-10-26 21:54                 ` Anh Vo
  2007-10-26 22:34                 ` Adam Beneschan
                                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 56+ messages in thread
From: Anh Vo @ 2007-10-26 21:54 UTC (permalink / raw)


On Oct 26, 2:14 pm, andrew <andrew.carr...@okstate.edu> >
> Something seems to be wrong though.  In my program I am basiclly
> doing:
>
> start := clock;
> --I run my algorithm here
> finish := clock;
> ada.Text_IO.put_line("time = " & duration'image(to_duration(finish -
> start)));
>
> the output is always time = 0.000000000.  I know it had to take some
> time because it takes about 10 seconds for the program to reach that
> point in the code.  Overflow maybe?- Hide quoted text -
>

In that case use the conversion as shown bellow.

Put_Line (Duration'Image (To_Duration (finish - start)));

Check the Ada.Real_Time package specification you will see all
operators / operations used above.

AV





^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-26 21:14               ` andrew
  2007-10-26 21:54                 ` Anh Vo
@ 2007-10-26 22:34                 ` Adam Beneschan
  2007-10-27  1:58                 ` tmoran
  2007-10-27 12:40                 ` John McCormick
  3 siblings, 0 replies; 56+ messages in thread
From: Adam Beneschan @ 2007-10-26 22:34 UTC (permalink / raw)


On Oct 26, 2:14 pm, andrew <andrew.carr...@okstate.edu> wrote:

> Something seems to be wrong though.  In my program I am basiclly
> doing:
>
> start := clock;
> --I run my algorithm here
> finish := clock;
> ada.Text_IO.put_line("time = " & duration'image(to_duration(finish -
> start)));
>
> the output is always time = 0.000000000.  I know it had to take some
> time because it takes about 10 seconds for the program to reach that
> point in the code.  Overflow maybe?

The RM says that "Time" is supposed to be able to represent a value,
from program start, of at least 50 years.  So if a 10-second program
is overflowing that time, you've got a problem.

I tried a program similar to the above on two different compilers,
with "delay 10.0" in the place where you have "I run my algorithm
here"; and in both cases the output is around 10.0.  I don't know why
you'd be seeing zero, assuming the system you're on has a working
clock.  What type of machine are you running on, and what compiler?

                      -- Adam





^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-26 21:14               ` andrew
  2007-10-26 21:54                 ` Anh Vo
  2007-10-26 22:34                 ` Adam Beneschan
@ 2007-10-27  1:58                 ` tmoran
  2007-10-27 12:40                 ` John McCormick
  3 siblings, 0 replies; 56+ messages in thread
From: tmoran @ 2007-10-27  1:58 UTC (permalink / raw)


You might want to run/look-at the "time the clock" routine at
www.adapower.com
under "reuse", "misc", "tt"
It shows various measurements on how fast the clock ticks, what's the
minimal interval it can measure, etc.  It's written for Ada.Calendar
rather than Ada.Real_Time but could be changed (and they are probably the
same anyway).



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-26 14:58 Real Time IO routines andrew
  2007-10-26 16:43 ` Anh Vo
  2007-10-26 17:12 ` Ed Falis
@ 2007-10-27  8:56 ` anon
  2007-10-27 10:18   ` Dmitry A. Kazakov
  2 siblings, 1 reply; 56+ messages in thread
From: anon @ 2007-10-27  8:56 UTC (permalink / raw)


--
-- Simple answer is to build a IO package and use Unchecked_Conversion
--
with Ada.Real_Time ;  
with Ada.Text_IO ;
--
-- 
--
use  Ada.Real_Time ;
use  Ada.Text_IO ;

with Ada.Unchecked_Conversion ;

procedure z is 

   --
   -- I/O  Time ( Duration ) type.
   --
   package D_IO is new Ada.Text_IO.Fixed_IO ( Duration ) ;

   --
   -- convert Ada.Real_Time private Time to a local type.
   --
   function To_Duration is new Ada.Unchecked_Conversion 
              ( Time, Duration  ) ;


  Time_Value : Time ;

begin

  Time_Value := Clock ;

  Put ( "Time := " ) ;
  D_IO.Put ( To_Duration ( Time_Value ) ) ;

  New_Line ;

end z ;

In <1193410739.367181.96050@50g2000hsm.googlegroups.com>,  andrew <andrew.carroll@okstate.edu> writes:
>Hello,
>
>Is there a put or put_line procedure to output the value of variables
>declared as the Time type defined in the Real_Time package?
>




^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-27  8:56 ` anon
@ 2007-10-27 10:18   ` Dmitry A. Kazakov
  2007-10-27 20:15     ` anon
  0 siblings, 1 reply; 56+ messages in thread
From: Dmitry A. Kazakov @ 2007-10-27 10:18 UTC (permalink / raw)


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



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-26 21:14               ` andrew
                                   ` (2 preceding siblings ...)
  2007-10-27  1:58                 ` tmoran
@ 2007-10-27 12:40                 ` John McCormick
  2007-10-27 20:12                   ` andrew
  3 siblings, 1 reply; 56+ messages in thread
From: John McCormick @ 2007-10-27 12:40 UTC (permalink / raw)


On Oct 26, 4:14 pm, andrew <andrew.carr...@okstate.edu> wrote:
>
>
> start := clock;
> --I run my algorithm here
> finish := clock;
> ada.Text_IO.put_line("time = " & duration'image(to_duration(finish -
> start)));
>
> the output is always time = 0.000000000.  I know it had to take some
> time because it takes about 10 seconds for the program to reach that
> point in the code.  Overflow maybe?

For years I used the identical logic in an exercise in plotting
running times for various sorting algortihms in a unit on Big-O.  It
worked fine for the old GNAT (Ada 95).  Last year when I recompiled it
with GNAT GPL, I got the same results as you - all times gave zero.
When I added a delay 10.0, it worked as Adam reported.  I meant to
submit a bug report, but never got around to writing it up.  I haven't
tried it with the latest GPL version.

John





^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-27 12:40                 ` John McCormick
@ 2007-10-27 20:12                   ` andrew
  0 siblings, 0 replies; 56+ messages in thread
From: andrew @ 2007-10-27 20:12 UTC (permalink / raw)


On Oct 27, 7:40 am, John McCormick <mccorm...@cs.uni.edu> wrote:
> On Oct 26, 4:14 pm, andrew <andrew.carr...@okstate.edu> wrote:
>
>
>
> > start := clock;
> > --I run my algorithm here
> > finish := clock;
> > ada.Text_IO.put_line("time = " & duration'image(to_duration(finish -
> > start)));
>
> > the output is always time = 0.000000000.  I know it had to take some
> > time because it takes about 10 seconds for the program to reach that
> > point in the code.  Overflow maybe?
>
> For years I used the identical logic in an exercise in plotting
> running times for various sorting algortihms in a unit on Big-O.  It
> worked fine for the old GNAT (Ada 95).  Last year when I recompiled it
> with GNAT GPL, I got the same results as you - all times gave zero.
> When I added a delay 10.0, it worked as Adam reported.  I meant to
> submit a bug report, but never got around to writing it up.  I haven't
> tried it with the latest GPL version.
>
> John

Ahhh haaa, that's it.  I put a delay 1.0 before I run my algorithm and
before I do start := clock and now it gives me a value.  ;-)

Dare I say something is not quite right?




^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-27 10:18   ` Dmitry A. Kazakov
@ 2007-10-27 20:15     ` anon
  2007-10-27 20:49       ` Dmitry A. Kazakov
                         ` (4 more replies)
  0 siblings, 5 replies; 56+ messages in thread
From: anon @ 2007-10-27 20:15 UTC (permalink / raw)


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@40tude.net>, "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de> 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




^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-27 20:15     ` anon
@ 2007-10-27 20:49       ` Dmitry A. Kazakov
  2007-10-27 21:51       ` Simon Wright
                         ` (3 subsequent siblings)
  4 siblings, 0 replies; 56+ messages in thread
From: Dmitry A. Kazakov @ 2007-10-27 20:49 UTC (permalink / raw)


On Sat, 27 Oct 2007 20:15:15 GMT, anon wrote:

> Plus, the "Ada.Real_Time" package uses:
> 
>    type Time is new Duration;
> 
> which is in private section.

The standard defines the private section of as:

private
   ... -- not specified by the language
end Ada.Real_Time;

See ARM D.7.

To make the program dependant on whatever private parts of library packages
is an even worse idea than just converting Time to Duration. The latter is
just semantically wrong, but the former is wrong methodologically.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-27 20:15     ` anon
  2007-10-27 20:49       ` Dmitry A. Kazakov
@ 2007-10-27 21:51       ` Simon Wright
  2007-10-28 11:35         ` Ludovic Brenta
                           ` (2 more replies)
  2007-10-28  1:15       ` Real Time IO routines Jeffrey Creem
                         ` (2 subsequent siblings)
  4 siblings, 3 replies; 56+ messages in thread
From: Simon Wright @ 2007-10-27 21:51 UTC (permalink / raw)


anon@anon.org (anon) writes:

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

I must be a newbie (NB spelling!) then.

Where on earth do you get this viewpoint from? Please say why it is
better to instantiate enumeration IO for Boolean rather than to use
Boolean'Image?

I suppose you would ban people from using Integer_IO, too. Good grief.

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

This is true so long as you and the person to whom you are giving
advice are both using *this version of* *GNAT*. Whatever makes you
suppose that the code you see in that private part will be the same
for any other compiler? or for any other version of GNAT? or for GNAT
for a different platform?



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-27 20:15     ` anon
  2007-10-27 20:49       ` Dmitry A. Kazakov
  2007-10-27 21:51       ` Simon Wright
@ 2007-10-28  1:15       ` Jeffrey Creem
  2007-10-29 16:18       ` Adam Beneschan
  2007-10-29 18:53       ` andrew
  4 siblings, 0 replies; 56+ messages in thread
From: Jeffrey Creem @ 2007-10-28  1:15 UTC (permalink / raw)


anon wrote:
> 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.
> 

That is true. They also never use the * to do integer multiplication 
when clearly can just write a function that performs repetitive 
addition...;)

Honestly you are one of the most confusing posters on the newsgroup in 
many years. Some postings seem well informed and thought out but others. 
seem quite odd. Is there more than one anon?





^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-27 21:51       ` Simon Wright
@ 2007-10-28 11:35         ` Ludovic Brenta
  2007-10-30 14:37           ` Simon Clubley
  2007-10-29 19:28         ` Real Time IO routines -- answering Simon Wright part 1 anon
  2007-10-30 16:35         ` Real Time IO routines answering Simon Wright part 2 anon
  2 siblings, 1 reply; 56+ messages in thread
From: Ludovic Brenta @ 2007-10-28 11:35 UTC (permalink / raw)


Simon Wright <simon.j.wright@mac.com> writes:
> anon@anon.org (anon) writes:
>
>> 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.
>
> I must be a newbie (NB spelling!) then.
>
> Where on earth do you get this viewpoint from? Please say why it is
> better to instantiate enumeration IO for Boolean rather than to use
> Boolean'Image?

At Barco avionics, our coding standard prohibits functions that return
unconstrained types because they use the secondary stack, making
inspection of object code more difficult.  That prohibition applies to
'Image, too.  But outside of safety-critical software, I see no reason
why 'Image should be prohibited.

-- 
Ludovic Brenta.



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-27 20:15     ` anon
                         ` (2 preceding siblings ...)
  2007-10-28  1:15       ` Real Time IO routines Jeffrey Creem
@ 2007-10-29 16:18       ` Adam Beneschan
  2007-10-29 16:40         ` Robert A Duff
                           ` (3 more replies)
  2007-10-29 18:53       ` andrew
  4 siblings, 4 replies; 56+ messages in thread
From: Adam Beneschan @ 2007-10-29 16:18 UTC (permalink / raw)


On Oct 27, 1:15 pm, a...@anon.org (anon) wrote:
> 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.

Sorry, that's just nonsense.  The semantics and result of 'Image are
well-defined by the language.  If those semantics are acceptable for a
particular use, then there's nothing wrong with using 'Image (unless
there's an issue with using a secondary stack as Ludovic mentioned).
If they're not, then don't use it.  'Image does not return things in a
way that makes it amenable to nicely formatted reports where things
line up.  (If you are creating a report with real numbers where you
want all the decimal points to line up, 'Image is probably not
best.)   Other than that, I can see no reason not to use 'Image except
that perhaps it has been decreed impure by the High Priests of Purity,
who apparently have determined this in some ritual in which they dance
around a statue of Ada Lovelace and burn huge listings of C++ code and
chant some incantation to ask the statue what constructs are
considered holy and pure.  That's the only reason I can think of---
there doesn't seem to be any reason based in practical benefit to
anyone.  On the other hand, any ritual in which a bunch of C++ code is
burned can't be all bad.

P.S. I have been working with Ada for 19 years and I use 'Image when
it's appropriate.  I'm definitely not a newbie.

                               -- Adam




^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-29 16:18       ` Adam Beneschan
@ 2007-10-29 16:40         ` Robert A Duff
  2007-10-29 17:26           ` Adam Beneschan
  2007-10-29 17:25         ` Jean-Pierre Rosen
                           ` (2 subsequent siblings)
  3 siblings, 1 reply; 56+ messages in thread
From: Robert A Duff @ 2007-10-29 16:40 UTC (permalink / raw)


Adam Beneschan <adam@irvine.com> writes:

> ... The semantics and result of 'Image are
> well-defined by the language.  If those semantics are acceptable for a
> particular use, then there's nothing wrong with using 'Image (unless
> there's an issue with using a secondary stack as Ludovic mentioned).

True.  But it's pretty annoying that:

'Image of integers includes an unwanted leading space.

'Image does not provide the formatting control that Text_IO does.

You have to include the name of the type in the code.

'Image of enumeration literals does not print what appears in the source
code -- it converts to ALL_CAPS.

- Bob



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-29 16:18       ` Adam Beneschan
  2007-10-29 16:40         ` Robert A Duff
@ 2007-10-29 17:25         ` Jean-Pierre Rosen
  2007-11-15  4:27         ` Randy Brukardt
  2007-11-15  4:27         ` Randy Brukardt
  3 siblings, 0 replies; 56+ messages in thread
From: Jean-Pierre Rosen @ 2007-10-29 17:25 UTC (permalink / raw)


Adam Beneschan a �crit :
> Sorry, that's just nonsense.  The semantics and result of 'Image are
> well-defined by the language.  If those semantics are acceptable for a
> particular use, then there's nothing wrong with using 'Image (unless
> there's an issue with using a secondary stack as Ludovic mentioned).
> If they're not, then don't use it.  'Image does not return things in a
> way that makes it amenable to nicely formatted reports where things
> line up.  (If you are creating a report with real numbers where you
> want all the decimal points to line up, 'Image is probably not
> best.)   Other than that, I can see no reason not to use 'Image

There is an important reason that many people forget. Compare:
    put_line (Integer'image(I));
with
    put (I);  -- Assuming proper instantiation of Integer_IO

If the line length is bounded and there remains not enough space on the 
line to accomodate the number, the former will write the number "across" 
the line break, while the latter will insert a EOL mark before the 
number and write the whole number on the next line.

-- 
---------------------------------------------------------
            J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-29 16:40         ` Robert A Duff
@ 2007-10-29 17:26           ` Adam Beneschan
  2007-10-29 22:34             ` Keith Thompson
  0 siblings, 1 reply; 56+ messages in thread
From: Adam Beneschan @ 2007-10-29 17:26 UTC (permalink / raw)


On Oct 29, 9:40 am, Robert A Duff <bobd...@shell01.TheWorld.com>
wrote:
> Adam Beneschan <a...@irvine.com> writes:
> > ... The semantics and result of 'Image are
> > well-defined by the language.  If those semantics are acceptable for a
> > particular use, then there's nothing wrong with using 'Image (unless
> > there's an issue with using a secondary stack as Ludovic mentioned).
>
> True.  But it's pretty annoying that:
>
> 'Image of integers includes an unwanted leading space.
>
> 'Image does not provide the formatting control that Text_IO does.
>
> You have to include the name of the type in the code.
>
> 'Image of enumeration literals does not print what appears in the source
> code -- it converts to ALL_CAPS.

I agree with all of those.  Nevertheless, as far as #1, #2, and #4 are
concerned, the result is still acceptable in some instances, and the
fact that it would not be good enough in some cases isn't any
particular reason to decree that it should never ever ever be used.
As for #1, I've often written my own function that declares a string S
whose value is 'Image and then returns S(S'First+1..S'Last) to get rid
of the leading space---this was before Trim functions became available
in Ada 95.  It's still more convenient than instantiating Integer_IO,
or writing your own function that uses division and "mod".  I believe
GNAT does have an 'Img attribute that can be applied to an object
(although I assume you still need 'Image for certain types of
expressions that are not valid attribute prefixes).  I don't know
whether this was ever proposed as a language addition, and if so why
it was rejected.

                        -- Adam






^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-27 20:15     ` anon
                         ` (3 preceding siblings ...)
  2007-10-29 16:18       ` Adam Beneschan
@ 2007-10-29 18:53       ` andrew
  2007-10-29 22:35         ` Keith Thompson
  4 siblings, 1 reply; 56+ messages in thread
From: andrew @ 2007-10-29 18:53 UTC (permalink / raw)


On Oct 27, 3:15 pm, a...@anon.org (anon) wrote:
>
> Mostly programs that are created by newbees use IMAGE attribute.
>

Ehh, sounds like an excuse to jab me in the eye.  WHO CARES ANON!  I'm
writing a program for a college class not something to send the
shuttle to Mars!!




^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines -- answering Simon Wright part 1
  2007-10-27 21:51       ` Simon Wright
  2007-10-28 11:35         ` Ludovic Brenta
@ 2007-10-29 19:28         ` anon
  2007-10-29 21:24           ` Georg Bauhaus
  2007-10-29 22:38           ` Keith Thompson
  2007-10-30 16:35         ` Real Time IO routines answering Simon Wright part 2 anon
  2 siblings, 2 replies; 56+ messages in thread
From: anon @ 2007-10-29 19:28 UTC (permalink / raw)


-- This answer is in two parts!  This part answers you question about 
-- use of enumeration Boolean package and using the IMAGE attribute 
-- versus using IO packages versus use user create routines. 
--
-- Now, for Boolean it is kind of funny because there is only two 
-- valid values (True and False). But it can illustrate some of 
-- the reasons.
--
-- Basically, what's wrong with the IMAGE attribute?
--
--   Using IMAGE Attribute. Output formatted and style set by vendor
--   and the output format is not specified in Ada RM.
--     1.For numeric data. No formatted output.  
--       A) No data "Width" control for output.
--       B) No field formatting. Such as setting the "Fore", 
--          "Aft" or "Exp" fields.
--       C) No base control.
--       D) No readability formatting. Such as adding "_" or commas
--          in numeric data printed output stream. 
--     2. For non-numeric, enumeration types, Upper-case string values
--        only.
--     3. Can not be used for complete "Arrays" or "Records". Only 
--        single elements of the "Record" or "Array" at a time.
-- 
-- Now with using standard IO packages like generic packages Text_IO 
-- packages.
--     1.For numeric data. Formatted Output
--       A) Full width control.
--       B) Full field formatting. Link setting the "Fore", "Aft" or 
--          "Exp" values.
--       C) Ada Standard Base formatting control.
--       D) No readability formatting. Such as adding "_" or commas 
--          in numeric data printed output stream. 
--     2. For non-numeric, enumeration types, 
--       A) Set Lower or Upper case 
--       B) Width spacing control.
--     3. Limited printing of the complete fields of a "Record" or 
--        "Arrays" using other IO packages like Sequential_IO. But 
--        no formatting allowed. The output will be in a "Raw" and 
--        even can be packed state.
-- 
--                    The Ada purist way!
-- Internal programmer-create IO routines and packages. 
--     1.For numeric data. Full Formatted Output controls for
--       A) Width control.
--       B) Field control. Setting the "Fore", "Aft" or "Exp" 
--        values.
--       C) Full Base formatting control. Even beyond Ada Standards
--       D) Readability formatting. IO algorithm can insert '_' or 
--          commas in numeric data.
--     2. For non-numeric, enumeration types, values printed the way 
--        the programmer chooses.
--     3. Full access to print parts or complete "Record" and "Array" 
--        elements in any format and form that a programmer can create.
-- 
-- 

--
-- t.adb -- Test all three versions for Boolean type. 
--
with Ada.Text_IO ;
use  Ada.Text_IO ;

procedure t is 
   --
   -- I/O package for Boolean type.
   --
   package B_IO is new Ada.Text_IO.Enumeration_IO ( Boolean ) ;


   --
   -- Put: Internal. Allows programmer to fully format the 
   --      output the way the programmer's wants. Could be 
   --      a routine in a programmer created package.
   --
   -- Plus this internal PUT routine is more efficient
   -- than either the IMAGE or Package versions. Do to the 
   -- fact that the programmer can controller how the code 
   -- is generated by using "pragmas" and controlling the 
   -- optimization level. Also knows what type of code will 
   -- be  generated.
   --
   -- Also, this routine reduces dead (unused) routines in 
   -- the partition file which reduces the amount of program 
   -- code loaded into memory during execution.
   --
   procedure Put ( V : Boolean ) is
     begin -- Put
       if V then
         Put ( "Yes" ) ; --  altered version of TRUE
       else
         Put ( "No" ) ; --  altered version of FALSE
       end if ;
     end Put ;


  Value  : Boolean := False ;

begin

  Put ( "Image Value := " ) ; 
  --
  -- VENDOR Controlled
  -- Output: Upper case only, No width control.
  --
  -- This statement besides the code generated by the call to  
  -- "Ada.Text_IO.Put ( string ) ;" routine. Will generated an 
  -- indeterminate number of cpu instructions (depend on the vendor).  
  -- And will include anywhere from 2 to 5 extra packages (again depend 
  -- on the vendor) which can have dead code and have an indeterminate 
  -- algorithm for generating the actual image. For the Boolean type it 
  -- could be a simple "if-then-else" routine, but since Boolean is an 
  -- enumeration type the algorithm could be more complex than that, 
  -- which could decrease the performance of the partition.
  --
  Put ( Boolean'Image ( Value ) ) ; 
  New_Line ;

  -- 
  -- Using a package. Programmer define Case and Width Controls.
  --
  -- In using a generic IO package, there are a number of 
  -- concerns. The first is the amount of dead code and memory 
  -- required to load this code.  The second is will this IO 
  -- package require addition statements, such as "Open", "Close"
  -- and etc.  Also will it interfere with other screen IO 
  -- routines. The Plus, side is the formatting of the data.  In 
  -- the case of a Boolean Type that is altering the case and 
  -- setting of spacing 
  --
  Put ( "Package IO Value := " ) ;
  B_IO.Put ( Value ) ; -- default to upper case.
  New_Line ;
  --
  -- Define alternate width and case values for package version.
  -- Will set field with to 6 spaces and out to lower case.
  --
  Value := True ;
  Put ( "Package IO Value := " ) ;
  B_IO.Put ( Item => Value, Width => 6, Set => Lower_Case ) ;
  New_Line ;


  --
  -- Then there is the full control over data being displayed.
  --
  Put ( "IO Routine Value := " ) ;
  T.Put ( Value ) ;
  New_Line ;

end t ;

In <m2tzoc5iqw.fsf@mac.com>, Simon Wright <simon.j.wright@mac.com> writes:
>anon@anon.org (anon) writes:
>
>> 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.
>
>I must be a newbie (NB spelling!) then.
>
>Where on earth do you get this viewpoint from? Please say why it is
>better to instantiate enumeration IO for Boolean rather than to use
>Boolean'Image?
>
>I suppose you would ban people from using Integer_IO, too. Good grief.
>
>> 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. 
>
>This is true so long as you and the person to whom you are giving
>advice are both using *this version of* *GNAT*. Whatever makes you
>suppose that the code you see in that private part will be the same
>for any other compiler? or for any other version of GNAT? or for GNAT
>for a different platform?




^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines -- answering Simon Wright part 1
  2007-10-29 19:28         ` Real Time IO routines -- answering Simon Wright part 1 anon
@ 2007-10-29 21:24           ` Georg Bauhaus
  2007-10-29 21:31             ` Georg Bauhaus
  2007-10-29 22:01             ` Dmitry A. Kazakov
  2007-10-29 22:38           ` Keith Thompson
  1 sibling, 2 replies; 56+ messages in thread
From: Georg Bauhaus @ 2007-10-29 21:24 UTC (permalink / raw)


On Mon, 2007-10-29 at 19:28 +0000, anon wrote:

> -- Basically, what's wrong with the IMAGE attribute?
> --
> --   Using IMAGE Attribute. Output formatted and style set by vendor
> --   and the output format is not specified in Ada RM.
>
> [examples of formatted I/O]

True, programming of formatted I/O of values in general
requires this approach. Text_IO.Editing is also quite
nice (though it is not available with every compiler...).

But, IO packages help with _formatted_ output of
non-String values. _Formatted_ output of simple String values
will, by comparison, require formatting efforts, too!
Same requirements, same approach. I can think of many good
reasons  to just write unformatted string values to
Current_Output. (Which is 'Pseudo_Image for Strings ;-) [1]
For example, tabulation may require narrowing to columns,
paragraphs might have to be shaped, words truncated etc..
The circumstances are similar to those requiring numbers
with Aft, say.

  So using 'Image or not seems a use case issue to me.
Seen from this point of view, the language, or some
notion of purity, cannot decide what the use case is.

Using IO packages can,
in my view, also be over the top when programmers apply their
stylistic preferences to external representations of output,
possibly, and unintentionally, hiding valuable information
that would in fact be produced by 'Image, if used with someone
else's Ada system.

 [1] I guess this sounds silly, but I don't see numbers to be
special for the moment: For the reader, a word is an approximation
of a value, too.






^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines -- answering Simon Wright part 1
  2007-10-29 21:24           ` Georg Bauhaus
@ 2007-10-29 21:31             ` Georg Bauhaus
  2007-10-29 22:01             ` Dmitry A. Kazakov
  1 sibling, 0 replies; 56+ messages in thread
From: Georg Bauhaus @ 2007-10-29 21:31 UTC (permalink / raw)


On Mon, 2007-10-29 at 22:24 +0100, Georg Bauhaus wrote:

More clearly, the following paragraph was meant to show
why a simple output of string values is just as good or
bad as a simple output of S'Image(V).  So when there is
nothing wrong with simple output of, e.g., plain vanilla
text strings, why is there something wrong with simple
output of non-text values?
> For example, tabulation may require narrowing to columns,
> paragraphs might have to be shaped, words truncated etc..
> The circumstances are similar to those requiring numbers
> with Aft, say.






^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines -- answering Simon Wright part 1
  2007-10-29 21:24           ` Georg Bauhaus
  2007-10-29 21:31             ` Georg Bauhaus
@ 2007-10-29 22:01             ` Dmitry A. Kazakov
  1 sibling, 0 replies; 56+ messages in thread
From: Dmitry A. Kazakov @ 2007-10-29 22:01 UTC (permalink / raw)


On Mon, 29 Oct 2007 22:24:20 +0100, Georg Bauhaus wrote:

>   So using 'Image or not seems a use case issue to me.
> Seen from this point of view, the language, or some
> notion of purity, cannot decide what the use case is.

Right, this is why an equivalent of 'Image is often preferable to Text_IO.
Because it does not add so much unnecessary stuff and its does not limit
you to where and how the image will be placed. Usually for text rendering
you would better have normal string images of values which are then
aligned, wrapped, colored, shaped etc in some way. It is a bad idea to try
to pack all this in one call like Put. The fact that the built-in 'Image is
not very usable, for many reasons already mentioned by others, changes here
little. I just use my own equivalents instead. For example, I prefer UTF-8
subscript for the number base (rather than ugly 16#...#) and superscript
for its exponent part, when I do GTK+ GUI.

So "use case" is indeed an important point. The original poster said
nothing about the use case, so I used Image just in order to illustrate my
point. Which was that Unchecked_Conversion of Time to Duration is an ugly
non-portable hack, which is absolutely unnecessary, because Ada.Real_Time
already provides Spilt for the purpose of getting seconds since the epoch.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-29 17:26           ` Adam Beneschan
@ 2007-10-29 22:34             ` Keith Thompson
  0 siblings, 0 replies; 56+ messages in thread
From: Keith Thompson @ 2007-10-29 22:34 UTC (permalink / raw)


Adam Beneschan <adam@irvine.com> writes:
> On Oct 29, 9:40 am, Robert A Duff <bobd...@shell01.TheWorld.com>
> wrote:
>> Adam Beneschan <a...@irvine.com> writes:
>> > ... The semantics and result of 'Image are
>> > well-defined by the language.  If those semantics are acceptable for a
>> > particular use, then there's nothing wrong with using 'Image (unless
>> > there's an issue with using a secondary stack as Ludovic mentioned).
>>
>> True.  But it's pretty annoying that:
>>
>> 'Image of integers includes an unwanted leading space.
[...]
> As for #1, I've often written my own function that declares a string S
> whose value is 'Image and then returns S(S'First+1..S'Last) to get rid
> of the leading space---this was before Trim functions became available
> in Ada 95.

I hope you check that the value is non-negative before deleting the
first character.

[...]

> I believe GNAT does have an 'Img attribute that can be applied to an
> object (although I assume you still need 'Image for certain types of
> expressions that are not valid attribute prefixes).  I don't know
> whether this was ever proposed as a language addition, and if so why
> it was rejected.

GNAT's 'Img does the same leading-space thing that the standard 'Image
does.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-29 18:53       ` andrew
@ 2007-10-29 22:35         ` Keith Thompson
  0 siblings, 0 replies; 56+ messages in thread
From: Keith Thompson @ 2007-10-29 22:35 UTC (permalink / raw)


andrew <andrew.carroll@okstate.edu> writes:
> On Oct 27, 3:15 pm, a...@anon.org (anon) wrote:
>> Mostly programs that are created by newbees use IMAGE attribute.
>
> Ehh, sounds like an excuse to jab me in the eye.  WHO CARES ANON!  I'm
> writing a program for a college class not something to send the
> shuttle to Mars!!

Even if you were, the Image attribute would be perfectly appropriate
if it met your needs.  "anon" is wrong.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines -- answering Simon Wright part 1
  2007-10-29 19:28         ` Real Time IO routines -- answering Simon Wright part 1 anon
  2007-10-29 21:24           ` Georg Bauhaus
@ 2007-10-29 22:38           ` Keith Thompson
  2007-10-30  0:58             ` tmoran
  1 sibling, 1 reply; 56+ messages in thread
From: Keith Thompson @ 2007-10-29 22:38 UTC (permalink / raw)


anon@anon.org (anon) writes:
[...]
> -- Basically, what's wrong with the IMAGE attribute?
> --
> --   Using IMAGE Attribute. Output formatted and style set by vendor
> --   and the output format is not specified in Ada RM.

Wrong.  The result of the 'Image attribute is specified by the
language, not by the vendor.

> --     1.For numeric data. No formatted output.  
> --       A) No data "Width" control for output.
> --       B) No field formatting. Such as setting the "Fore", 
> --          "Aft" or "Exp" fields.
> --       C) No base control.
> --       D) No readability formatting. Such as adding "_" or commas
> --          in numeric data printed output stream. 

The 'Image attribute is less flexible than some other solutions.
Nobody has claimed otherwise.

If the behavior of 'Image happens to be satisfactory for your
purposes, there's no reason not to use it.  If it isn't, then
obviously you should use something else.

-- 
Keith Thompson (The_Other_Keith) kst-u@mib.org  <http://www.ghoti.net/~kst>
San Diego Supercomputer Center             <*>  <http://users.sdsc.edu/~kst>
"We must do something.  This is something.  Therefore, we must do this."
    -- Antony Jay and Jonathan Lynn, "Yes Minister"



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines -- answering Simon Wright part 1
  2007-10-29 22:38           ` Keith Thompson
@ 2007-10-30  0:58             ` tmoran
  0 siblings, 0 replies; 56+ messages in thread
From: tmoran @ 2007-10-30  0:58 UTC (permalink / raw)


> If the behavior of 'Image happens to be satisfactory for your
> purposes, there's no reason not to use it.  If it isn't, then
> obviously you should use something else.

And if it is satisfactory there is good reason *not* to build your own.
Every extra line of code is an opportunity for error, for confusing
a reader, and for code bloat.



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-30 14:37           ` Simon Clubley
@ 2007-10-30 13:47             ` Ludovic Brenta
  2007-10-30 14:46             ` Jean-Pierre Rosen
  1 sibling, 0 replies; 56+ messages in thread
From: Ludovic Brenta @ 2007-10-30 13:47 UTC (permalink / raw)


Simon Clubley wrote:
> Ludovic Brenta <ludo...@ludovic-brenta.org> writes:
> > At Barco avionics, our coding standard prohibits functions that return
> > unconstrained types because they use the secondary stack, making
> > inspection of object code more difficult.  That prohibition applies to
> > 'Image, too.  But outside of safety-critical software, I see no reason
> > why 'Image should be prohibited.
>
> Is your coding standard freely available by any chance ?
>
> I'd be interested in seeing what other Ada features are not allowed in
> your code as well as what other recommendations that your standard
> might make.

No, it's not. It is proprietary due to corporate policy.

--
Ludovic Brenta.




^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-28 11:35         ` Ludovic Brenta
@ 2007-10-30 14:37           ` Simon Clubley
  2007-10-30 13:47             ` Ludovic Brenta
  2007-10-30 14:46             ` Jean-Pierre Rosen
  0 siblings, 2 replies; 56+ messages in thread
From: Simon Clubley @ 2007-10-30 14:37 UTC (permalink / raw)


In article <87hckbeajm.fsf@ludovic-brenta.org>, Ludovic Brenta <ludovic@ludovic-brenta.org> writes:
> 
> At Barco avionics, our coding standard prohibits functions that return
> unconstrained types because they use the secondary stack, making
> inspection of object code more difficult.  That prohibition applies to
> 'Image, too.  But outside of safety-critical software, I see no reason
> why 'Image should be prohibited.
> 

Is your coding standard freely available by any chance ?

I'd be interested in seeing what other Ada features are not allowed in
your code as well as what other recommendations that your standard
might make.

Thanks,

Simon.

-- 
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Microsoft: Bringing you 1980's technology to a 21st century world



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-30 14:37           ` Simon Clubley
  2007-10-30 13:47             ` Ludovic Brenta
@ 2007-10-30 14:46             ` Jean-Pierre Rosen
  2007-10-31 14:38               ` Ada coding standards, was: " Simon Clubley
  1 sibling, 1 reply; 56+ messages in thread
From: Jean-Pierre Rosen @ 2007-10-30 14:46 UTC (permalink / raw)


Simon Clubley a �crit :
> In article <87hckbeajm.fsf@ludovic-brenta.org>, Ludovic Brenta <ludovic@ludovic-brenta.org> writes:

> I'd be interested in seeing what other Ada features are not allowed in
> your code as well as what other recommendations that your standard
> might make.

FYI, NASA rules are available at 
http://fsw.gsfc.nasa.gov/gds/code_standards_ada.pdf

And of course, if you want ideas about coding rules, you are welcome to 
read the AdaControl user's guide at 
http://www.adalog.fr/compo/adacontrol_ug.html

-- 
---------------------------------------------------------
            J-P. Rosen (rosen@adalog.fr)
Visit Adalog's web site at http://www.adalog.fr



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines answering Simon Wright part 2
  2007-10-27 21:51       ` Simon Wright
  2007-10-28 11:35         ` Ludovic Brenta
  2007-10-29 19:28         ` Real Time IO routines -- answering Simon Wright part 1 anon
@ 2007-10-30 16:35         ` anon
  2007-10-30 21:50           ` Simon Wright
  2007-10-31 15:35           ` Adam Beneschan
  2 siblings, 2 replies; 56+ messages in thread
From: anon @ 2007-10-30 16:35 UTC (permalink / raw)


--
--  This is Part 2. A simpler version of an Ada purist type of 
--  answer to the original thread poster question. Also ths 
--  version should answer "Dmitry A. Kazakov" concerns about 
--  types being defined in private. The RM does have its view on 
--  this version.
--

--
--  Where did I get the information that IMAGE should be use for 
--  debugging only? A few Ada conferences back in the early to 
--  mid 1990's dealing with Ada programming and debugging 
--  techniques. And is fully embrased by Adacore aka creaters of 
--  GNAT.
--

--
-- z.adb
--
--
--  Compile with "-gnatwI" or you may receive Portable and Version 
--  Warnings, for the sub package "ada.real_time.io" aka user-written
--  child of "ada.real_time". (GNAT)
--

with Ada.Real_Time ;  
with Ada.Real_Time.IO ;  -- programmer Ada extension package
with Ada.Text_IO ;

use  Ada.Real_Time ;
use  Ada.Text_IO ;


procedure z is 

    Time_Value : Time ;

  begin

  Time_Value := Clock ;

  Put ( "Time := " ) ;
  Ada.Real_Time.IO.Put ( Time_Value ) ;

  New_Line ;

end z ;


--
--  a-retiio.ads
--
--  Package must be included with program source code, do to 
--  the "non-Portable" nature of this code.
--
package Ada.Real_Time.IO is

  --
  -- Put: Uses the default Put routine. To keep this example 
  --      simple the routines uses the type default for 
  --      formatting  
  --
  procedure Put ( Z : Time ) ;

end Ada.Real_Time.IO ;


--
--  a-retiio.adb  =>  Ada Standard Extension Package.
--
pragma Style_Checks (OFF);         --  not needed if you use GNAT style
                                   --  requirements aka rules for spacing
 
--
--  Gnat will view this package as a "Language Defined Unit" even 
--  though it is not in the Standard GNAT package list.
--
--  Package must be included with program source code, do to 
--  the "non-Portable" nature of this code.
--

-- ------------------------------------------------------- --
--   An Ada Purist would have bypassed using a package     --
--   routine and added a local routine for printing the    -- 
--   "Time" value directly to a text file. That way they   --
--   could reduce the code to the bare bones.              --
-- ------------------------------------------------------- --
--   I used a generic package because it was faster and    --
--   easier to generate the example of an extension to     --
--   the Standard Ada packages.                            --
-- ------------------------------------------------------- --

with Ada.Text_IO ;

package body Ada.Real_Time.IO is

  --
  -- Time specification comes from the parent's code.
  --   
  package D_IO is new Ada.Text_IO.Fixed_IO ( Time ) ;


  --
  -- Put: Uses the default Put routine. To keep this example 
  --      simple the routines uses the type default for 
  --      formatting  
  --
  procedure Put ( Z : Time ) is

    begin -- Put

      D_IO.Put ( Z ) ;

    end Put ;

end Ada.Real_Time.IO ;


In <m2tzoc5iqw.fsf@mac.com>, Simon Wright <simon.j.wright@mac.com> writes:
>anon@anon.org (anon) writes:
>
>> 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.
>
>I must be a newbie (NB spelling!) then.
>
>Where on earth do you get this viewpoint from? Please say why it is
>better to instantiate enumeration IO for Boolean rather than to use
>Boolean'Image?
>
>I suppose you would ban people from using Integer_IO, too. Good grief.
>
>> 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. 
>
>This is true so long as you and the person to whom you are giving
>advice are both using *this version of* *GNAT*. Whatever makes you
>suppose that the code you see in that private part will be the same
>for any other compiler? or for any other version of GNAT? or for GNAT
>for a different platform?




^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines answering Simon Wright part 2
  2007-10-30 16:35         ` Real Time IO routines answering Simon Wright part 2 anon
@ 2007-10-30 21:50           ` Simon Wright
  2007-10-31 15:35           ` Adam Beneschan
  1 sibling, 0 replies; 56+ messages in thread
From: Simon Wright @ 2007-10-30 21:50 UTC (permalink / raw)


anon@anon.org (anon) writes:

> with Ada.Text_IO ;
>
> package body Ada.Real_Time.IO is
>
>   --
>   -- Time specification comes from the parent's code.
>   --   
>   package D_IO is new Ada.Text_IO.Fixed_IO ( Time ) ;

Personally I see nothing intrinsically wrong with extending the RTL if
your compiler lets you.

But this is completely different from implying to the OP that it's OK
to use unchecked conversion from a private type.

And since Dmitry has posted a portable and legal way of doing it I
think we should do it his way!

--S



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Ada coding standards, was: Re: Real Time IO routines
  2007-10-30 14:46             ` Jean-Pierre Rosen
@ 2007-10-31 14:38               ` Simon Clubley
  2007-10-31 18:02                 ` anon
  0 siblings, 1 reply; 56+ messages in thread
From: Simon Clubley @ 2007-10-31 14:38 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 1009 bytes --]

In article <h3g7gf.hsj.ln@hunter.axlog.fr>, Jean-Pierre Rosen <rosen@adalog.fr> writes:
> Simon Clubley a �crit :
>> In article <87hckbeajm.fsf@ludovic-brenta.org>, Ludovic Brenta <ludovic@ludovic-brenta.org> writes:
> 
>> I'd be interested in seeing what other Ada features are not allowed in
>> your code as well as what other recommendations that your standard
>> might make.
> 
> FYI, NASA rules are available at 
> http://fsw.gsfc.nasa.gov/gds/code_standards_ada.pdf
> 

Thanks.

IIRC, the last time I was pointed to this, I was told that the other NASA
standards are not available. Does anyone know if that's still the case ?

> And of course, if you want ideas about coding rules, you are welcome to 
> read the AdaControl user's guide at 
> http://www.adalog.fr/compo/adacontrol_ug.html
> 

Interesting software (and something that I should really try out.)

Simon.

-- 
Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
Microsoft: Bringing you 1980's technology to a 21st century world



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines answering Simon Wright part 2
  2007-10-30 16:35         ` Real Time IO routines answering Simon Wright part 2 anon
  2007-10-30 21:50           ` Simon Wright
@ 2007-10-31 15:35           ` Adam Beneschan
  2007-10-31 20:08             ` anon
  1 sibling, 1 reply; 56+ messages in thread
From: Adam Beneschan @ 2007-10-31 15:35 UTC (permalink / raw)


On Oct 30, 9:35 am, a...@anon.org (anon) wrote:

> --  Where did I get the information that IMAGE should be use for
> --  debugging only? A few Ada conferences back in the early to
> --  mid 1990's dealing with Ada programming and debugging
> --  techniques.

To be precise, that should be called "opinion", not "information".
OK, so I wasn't at the conferences you mention, so I really don't know
how this "information" was presented or what the context was.  There
may have been reasons for discouraging its use---the secondary stack
may be one reason; another possible reason is that less-experienced
programmers were prone to misuse 'Image.  Or it could have been due to
efficiency concerns with passing unconstrained arrays around.  Or it
could have just been someone's personal idea about what Ada was
"supposed" to be.  Of course, there is no shortage of people who have
difficulty distinguishing their own opinions from factual
information.

If the "information" was that there was a consensus in the Ada
community that 'Image was to be avoided, maybe that was true---I don't
know---but on the other hand, I suspect that if it were true then
'Image wouldn't have been expanded.  In Ada 83, you could not use
'Image on floating or fixed-point types; in Ada 95, this capability
was added.  It would seem a little odd for those who decided on what
would be added to Ada 95---who are about as far from "newbie" as you
can get---to add this feature if there was a consensus that 'Image was
a bad thing.  Also, the responses on this thread (from people with a
lot of Ada experience) seem to indicate that there is no such
consensus.

Anyway, I can imagine that 'Image may be misused sometimes, and that
some people felt it should be discouraged.  But it's a big jump to go
from there to the absolute statements you made that Ada purists
"NEVER" use it, or that it is never used except for debugging, or that
practically only newbies use it.  Those statements are still nonsense.

                       -- Adam





^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Ada coding standards, was: Re: Real Time IO routines
  2007-10-31 14:38               ` Ada coding standards, was: " Simon Clubley
@ 2007-10-31 18:02                 ` anon
  2007-10-31 19:23                   ` Georg Bauhaus
                                     ` (2 more replies)
  0 siblings, 3 replies; 56+ messages in thread
From: anon @ 2007-10-31 18:02 UTC (permalink / raw)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2279 bytes --]

It seams that the paper is filled wilth errors.  

1. The standard is wriiten for another company which may or may not be 
apart of NASA. So is this the true NASA standards?

2. We all know that the ISO adopted the Ada 2005 aka Ada 2007 standards 
back in Jan 2007.  The NASA coding standard is dated in July, 2007 and 
stated that the ISO has not adopted the Ada 2005 standards.  So, either 
this is an error or the paper is just a redated older standard. 

3. In 2004 SGI installed a 512 CPU super computer for NASA that uses 
LINUX and Ada (Ada 95, SGI version).  The paper would have touch on 
that issue as well.  But the only Ada vendor that the paper talked about 
was GNAT and Ada 2005. NASA uses almost every software and hardware 
vendor out there. So, any standard would acknowledge this and state 
issues with each vendor and their implementation of Ada and other 
languages. This paper only uses talks about GNAT and Ada 2005.

And with Congress and the President watching NASA closely. There are too 
many questions or errors in this coding Standard for me to think that this 
is the Standard for NASA coding.



In <8BdoH$LrdKPe@eisner.encompasserve.org>, clubley@remove_me.eisner.decus.org-Earth.UFP (Simon Clubley) writes:
>In article <h3g7gf.hsj.ln@hunter.axlog.fr>, Jean-Pierre Rosen <rosen@adalog.fr> writes:
>> Simon Clubley a �crit :
>>> In article <87hckbeajm.fsf@ludovic-brenta.org>, Ludovic Brenta <ludovic@ludovic-brenta.org> writes:
>> 
>>> I'd be interested in seeing what other Ada features are not allowed in
>>> your code as well as what other recommendations that your standard
>>> might make.
>> 
>> FYI, NASA rules are available at 
>> http://fsw.gsfc.nasa.gov/gds/code_standards_ada.pdf
>> 
>
>Thanks.
>
>IIRC, the last time I was pointed to this, I was told that the other NASA
>standards are not available. Does anyone know if that's still the case ?
>
>> And of course, if you want ideas about coding rules, you are welcome to 
>> read the AdaControl user's guide at 
>> http://www.adalog.fr/compo/adacontrol_ug.html
>> 
>
>Interesting software (and something that I should really try out.)
>
>Simon.
>
>-- 
>Simon Clubley, clubley@remove_me.eisner.decus.org-Earth.UFP
>Microsoft: Bringing you 1980's technology to a 21st century world




^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Ada coding standards, was: Re: Real Time IO routines
  2007-10-31 18:02                 ` anon
@ 2007-10-31 19:23                   ` Georg Bauhaus
  2007-10-31 20:40                   ` John W. Kennedy
  2007-11-01 11:27                   ` Stephen Leake
  2 siblings, 0 replies; 56+ messages in thread
From: Georg Bauhaus @ 2007-10-31 19:23 UTC (permalink / raw)


On Wed, 2007-10-31 at 18:02 +0000, anon wrote:
> It seams that the paper is filled wilth errors.  
> 
> 1. The standard is wriiten for another company which may or may not be 
> apart of NASA. So is this the true NASA standards?

As the title page says,

	Goddard Dynamic Simulator
	Ada Coding Standard

If you cut the URL after gds, a web page shows up. It should
answer your questions.






^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines answering Simon Wright part 2
  2007-10-31 15:35           ` Adam Beneschan
@ 2007-10-31 20:08             ` anon
  2007-10-31 21:08               ` Georg Bauhaus
                                 ` (2 more replies)
  0 siblings, 3 replies; 56+ messages in thread
From: anon @ 2007-10-31 20:08 UTC (permalink / raw)



In 1990's, NYU/Adacore and others suggested this at a conference and 
the Ada committee voted this and a few other standards for the 
Ravenscar profile. And a few vendors even coded this into their 
Ravenscar profile for their compilers. (GNAT 3.00 had it embeded in the 
compiler)

From the information of the Ada committee, this was also suggested 
that it become apart of the next specification amendment to Ada. That 
would have been in the updated Ada 95 standard "ISO/IEC 8652:1995(E) 
with Corrigendum 1 and Amendment 1" back in 2001. 

What happen well I think it was the DOD and 1998 that killed the idea. 
Europe was one who do not like some of the Ada committee new standards, 
so when the US government pulled out, so did those standards including the 
new coding practices.

Just like some follow the "Ada coding style guide", some do not.  The 
only one that GNAT follows to letter is the spacing, which makes some 
of the code hard to read.  But the rule on limiting comments, well just 
look at some of GNAT specifications. If you say that they followed that 
rule well than I will be the next Pres of the US. Since the style in not 
enforce in the compiler like others languages then why follow them. For 
GNAT it is enforce by options by the programmer not the Specifications. 
But I and some others like to be able to read the code and understand 
what the programmer is doing and spacing with a lot of comments allow 
that.

Plus, most programmer start out by believing the "Core Algorithm" is the 
most important part of a partition.  But as any published programmer will 
tell you that "Documentation" is number one, followed by the "User 
Interface" and the last item is the "Core Algorithm". A published 
programmer will also tell any programmer that the "User Interface" 
should take about 75% of the coding time while the "Core Algorithm" 
should take less than 5%.

And even though Ada has no real GUI in the specification it does have 
some. Rather the data is printed to the monitor or to a printer, the user 
(or teacher in the case of students) wants to be able to read the results 
without eye stain and in a timely fashion, that is, only the valid 
significant data. Which means that a programmer has to formatted 
their outputted data in a fashion that is informative but not too much 
that it causes confusion or stain in the user.


And any 19 year programming vet. should knows this!!! And to allow a 
student to believe differently is just wrong. Unformatted output and bad 
programming practices should never be allowed in code, except as a 
teaching tool, with documentation that states this.  Even if the statement 
is legal, those techniques and statements are for DEBUGGING ONLY. No 
one else should see unformatted data except for the programmer, while 
testing his "Core Algorithm". 


Leaving you with the idea. Which would you per to look at or read for 8 
hours a day:

This " 11938588250.273822028"   or this "250.273" for relative 
information. 

Or would you like the TAX man to see that you have:

  588200.797647034  and reads it as 588288.88 because of eye stain 
  or reads it as  588_200.79 or even 588,200.79 which is correct.

  Note: .88 is the number is rounded to .80 and the 88s because 
        of eye stain. After a while '0' can look like '8'.

And in both cases the unformatted output will get the programmer 
fired.



In <1193844955.601875.108200@e34g2000pro.googlegroups.com>,  Adam Beneschan <adam@irvine.com> writes:
>On Oct 30, 9:35 am, a...@anon.org (anon) wrote:
>
>> --  Where did I get the information that IMAGE should be use for
>> --  debugging only? A few Ada conferences back in the early to
>> --  mid 1990's dealing with Ada programming and debugging
>> --  techniques.
>
>To be precise, that should be called "opinion", not "information".
>OK, so I wasn't at the conferences you mention, so I really don't know
>how this "information" was presented or what the context was.  There
>may have been reasons for discouraging its use---the secondary stack
>may be one reason; another possible reason is that less-experienced
>programmers were prone to misuse 'Image.  Or it could have been due to
>efficiency concerns with passing unconstrained arrays around.  Or it
>could have just been someone's personal idea about what Ada was
>"supposed" to be.  Of course, there is no shortage of people who have
>difficulty distinguishing their own opinions from factual
>information.
>
>If the "information" was that there was a consensus in the Ada
>community that 'Image was to be avoided, maybe that was true---I don't
>know---but on the other hand, I suspect that if it were true then
>'Image wouldn't have been expanded.  In Ada 83, you could not use
>'Image on floating or fixed-point types; in Ada 95, this capability
>was added.  It would seem a little odd for those who decided on what
>would be added to Ada 95---who are about as far from "newbie" as you
>can get---to add this feature if there was a consensus that 'Image was
>a bad thing.  Also, the responses on this thread (from people with a
>lot of Ada experience) seem to indicate that there is no such
>consensus.
>
>Anyway, I can imagine that 'Image may be misused sometimes, and that
>some people felt it should be discouraged.  But it's a big jump to go
>from there to the absolute statements you made that Ada purists
>"NEVER" use it, or that it is never used except for debugging, or that
>practically only newbies use it.  Those statements are still nonsense.
>
>                       -- Adam
>
>




^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Ada coding standards, was: Re: Real Time IO routines
  2007-10-31 18:02                 ` anon
  2007-10-31 19:23                   ` Georg Bauhaus
@ 2007-10-31 20:40                   ` John W. Kennedy
  2007-11-01 11:27                   ` Stephen Leake
  2 siblings, 0 replies; 56+ messages in thread
From: John W. Kennedy @ 2007-10-31 20:40 UTC (permalink / raw)


anon wrote:
> And with Congress and the President watching NASA closely. There are too 
> many questions or errors in this coding Standard for me to think that this 
> is the Standard for NASA coding.

Ah, but does the Standard mention Evolution without remembering to call 
it "only a theory"? Does it mention global warming at all?
-- 
John W. Kennedy
"Sweet, was Christ crucified to create this chat?"
   -- Charles Williams.  "Judgement at Chelmsford"



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines answering Simon Wright part 2
  2007-10-31 20:08             ` anon
@ 2007-10-31 21:08               ` Georg Bauhaus
  2007-10-31 21:42               ` Markus E L
  2007-11-01  1:00               ` Adam Beneschan
  2 siblings, 0 replies; 56+ messages in thread
From: Georg Bauhaus @ 2007-10-31 21:08 UTC (permalink / raw)


On Wed, 2007-10-31 at 20:08 +0000, anon wrote:

> Leaving you with the idea. Which would you per to look at or read for 8 
> hours a day:
> 
> This " 11938588250.273822028"   or this "250.273" for relative 
> information. 

Numbers should only be printed 500'123.45 
as every veteran Swiss mountaineer knows.

I'm	almost	certain	that	even	a	tab	junkie
would	allow	students	to	print	running	times
without	going	into	layman	psychology	of	perception
so	aptly	provided	by	the	design	of
Ada.Text_IO.Float_IO.


GNAT's non-standard 'Img was made for quick trace outputs.





^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines answering Simon Wright part 2
  2007-10-31 20:08             ` anon
  2007-10-31 21:08               ` Georg Bauhaus
@ 2007-10-31 21:42               ` Markus E L
  2007-11-01  1:00               ` Adam Beneschan
  2 siblings, 0 replies; 56+ messages in thread
From: Markus E L @ 2007-10-31 21:42 UTC (permalink / raw)



'anon AT anon DOT org (anon)' wrote:

> Plus, most programmer start out by believing the "Core Algorithm" is the 
> most important part of a partition.  But as any published programmer will 
> tell you that "Documentation" is number one, followed by the "User 
> Interface" and the last item is the "Core Algorithm". A published 
> programmer will also tell any programmer that the "User Interface" 
> should take about 75% of the coding time while the "Core Algorithm" 
> should take less than 5%.

Off the top of my head I'd say that around 95% of all statistics made
up on the spot are wrong.

- M




^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines answering Simon Wright part 2
  2007-10-31 20:08             ` anon
  2007-10-31 21:08               ` Georg Bauhaus
  2007-10-31 21:42               ` Markus E L
@ 2007-11-01  1:00               ` Adam Beneschan
  2 siblings, 0 replies; 56+ messages in thread
From: Adam Beneschan @ 2007-11-01  1:00 UTC (permalink / raw)


I don't know why I'm masochistic enough to keep up this silly
argument, but...

On Oct 31, 1:08 pm, a...@anon.org (anon) wrote:

> And even though Ada has no real GUI in the specification it does have
> some. Rather the data is printed to the monitor or to a printer, the user
> (or teacher in the case of students) wants to be able to read the results
> without eye stain and in a timely fashion, that is, only the valid
> significant data. Which means that a programmer has to formatted
> their outputted data in a fashion that is informative but not too much
> that it causes confusion or stain in the user.
>
> And any 19 year programming vet. should knows this!!!

As a 30-plus-year programming veteran (19 years with Ada), I also know
that there are uses of 'Image that do not involve generating output
that a person will have to read for 8 hours a day; and, in fact, there
are uses of 'Image that don't involve generating output at all.  Say
you have an Integer variable File_ID (OK, define your own integer type
if you think only newbies would use the predefined Integer types), and
you want to use that as part of a file name that you're going to
create.  (You already know File_ID is nonnegative.)  What on earth
would be wrong with something like:

  Ada.Text_IO.Create (New_File, Ada.Text_IO.Out_File,
     Name => "nfz_" & Ada.Strings.Fixed.Trim (Integer'Image (File_ID),
Both)
                    & ".txt");

And what would be the point of a coding standard that forces you to
use, say, an instance of Integer_IO to build the file name rather than
using 'Image?

Yet your argument seems to be that, because there are inappropriate
uses of 'Image where you should be generating nicely formatted output
(something I've already acknowledged), that therefore the *only*
appropriate use of 'Image is for debugging.  Sorry, that's just silly.

                      -- Adam





^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Ada coding standards, was: Re: Real Time IO routines
  2007-10-31 18:02                 ` anon
  2007-10-31 19:23                   ` Georg Bauhaus
  2007-10-31 20:40                   ` John W. Kennedy
@ 2007-11-01 11:27                   ` Stephen Leake
  2007-11-01 20:38                     ` anon
  2 siblings, 1 reply; 56+ messages in thread
From: Stephen Leake @ 2007-11-01 11:27 UTC (permalink / raw)


anon@anon.org (anon) writes:

> 1. The standard is wriiten for another company which may or may not
> be apart of NASA. 

Interesting. What gives you that impression? Apparently it is written
in a confusing way, because you are confused.

> So is this the true NASA standards?

http://fsw.gsfc.nasa.gov/gds/code_standards_ada.pdf is _not_ a
NASA-wide standard, it is just the standard used by my small group.

This is clearly stated in the first paragraph:

    This document presents the coding standards used by the Goddard
    Dynamic Simulator project for the Ada language.

The title also states that this is specific to a specific project:

    Goddard Dynamic Simulator Ada Coding Standard

> 2. We all know that the ISO adopted the Ada 2005 aka Ada 2007 standards 
> back in Jan 2007.  The NASA coding standard is dated in July, 2007 and 
> stated that the ISO has not adopted the Ada 2005 standards.  So, either 
> this is an error or the paper is just a redated older standard. 

Ah, thanks; I'll fix that.

Yes, I recently added information on using Ada 2005 structures, and
advice on when to use access types. But I forgot to update the status
of the standard.

> 3. In 2004 SGI installed a 512 CPU super computer for NASA that uses 
> LINUX and Ada (Ada 95, SGI version).  The paper would have touch on 
> that issue as well.  

No, my group does not use that computer.

> So, any standard would acknowledge this and state issues with each
> vendor and their implementation of Ada and other languages. 

Interesting. Why would a document called "Goddard Dynamic Simulator
Ada Coding Standard" address other projects and other languages?

-- 
-- Stephe



^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Ada coding standards, was: Re: Real Time IO routines
  2007-11-01 11:27                   ` Stephen Leake
@ 2007-11-01 20:38                     ` anon
  0 siblings, 0 replies; 56+ messages in thread
From: anon @ 2007-11-01 20:38 UTC (permalink / raw)


Why the question, was it for NASA. The rest of the standards at NASA 
states that this standard is for the NASA group or a NASA Team.

Plus, I am looking for the Upper-tier standard for all team for software 
programs

Since you documented GNAT a product of Adacore, it it seams that you 
should talk about others vendors as well.

Plus. most standards that use GNAT also state that they should include 
the following pragmas in the source code to insure compatibility. Or at 
least use one or more to limit those features of GNAT that are not 
allowed in the source code.

pragma Restrictions ( No_Implementation_Attributes ) ;
pragma Restrictions ( No_Implementation_Pragmas ) ;
pragma Restrictions ( No_Implementation_Restrictions ) ;


In <ufxzq5hpi.fsf@stephe-leake.org>, Stephen Leake <stephen_leake@stephe-leake.org> writes:
>anon@anon.org (anon) writes:
>
>> 1. The standard is wriiten for another company which may or may not
>> be apart of NASA. 
>
>Interesting. What gives you that impression? Apparently it is written
>in a confusing way, because you are confused.
>
>> So is this the true NASA standards?
>
>http://fsw.gsfc.nasa.gov/gds/code_standards_ada.pdf is _not_ a
>NASA-wide standard, it is just the standard used by my small group.
>
>This is clearly stated in the first paragraph:
>
>    This document presents the coding standards used by the Goddard
>    Dynamic Simulator project for the Ada language.
>
>The title also states that this is specific to a specific project:
>
>    Goddard Dynamic Simulator Ada Coding Standard
>
>> 2. We all know that the ISO adopted the Ada 2005 aka Ada 2007 standards 
>> back in Jan 2007.  The NASA coding standard is dated in July, 2007 and 
>> stated that the ISO has not adopted the Ada 2005 standards.  So, either 
>> this is an error or the paper is just a redated older standard. 
>
>Ah, thanks; I'll fix that.
>
>Yes, I recently added information on using Ada 2005 structures, and
>advice on when to use access types. But I forgot to update the status
>of the standard.
>
>> 3. In 2004 SGI installed a 512 CPU super computer for NASA that uses 
>> LINUX and Ada (Ada 95, SGI version).  The paper would have touch on 
>> that issue as well.  
>
>No, my group does not use that computer.
>
>> So, any standard would acknowledge this and state issues with each
>> vendor and their implementation of Ada and other languages. 
>
>Interesting. Why would a document called "Goddard Dynamic Simulator
>Ada Coding Standard" address other projects and other languages?
>
>-- 
>-- Stephe




^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-29 16:18       ` Adam Beneschan
                           ` (2 preceding siblings ...)
  2007-11-15  4:27         ` Randy Brukardt
@ 2007-11-15  4:27         ` Randy Brukardt
  3 siblings, 0 replies; 56+ messages in thread
From: Randy Brukardt @ 2007-11-15  4:27 UTC (permalink / raw)


"Adam Beneschan" <adam@irvine.com> wrote in message
news:1193674697.257242.163990@v23g2000prn.googlegroups.com...
...
> Other than that, I can see no reason not to use 'Image except
> that perhaps it has been decreed impure by the High Priests of Purity,
> who apparently have determined this in some ritual in which they dance
> around a statue of Ada Lovelace and burn huge listings of C++ code and
> chant some incantation to ask the statue what constructs are
> considered holy and pure.

I think I'll suggest that for the next ARG meeting. It'll break up the
monotony. ;-)

I think I'm going to have a hard time getting that image (pun intended) out
of my mind. Thanks for the laugh!

                              Randy.





^ permalink raw reply	[flat|nested] 56+ messages in thread

* Re: Real Time IO routines
  2007-10-29 16:18       ` Adam Beneschan
  2007-10-29 16:40         ` Robert A Duff
  2007-10-29 17:25         ` Jean-Pierre Rosen
@ 2007-11-15  4:27         ` Randy Brukardt
  2007-11-15  4:27         ` Randy Brukardt
  3 siblings, 0 replies; 56+ messages in thread
From: Randy Brukardt @ 2007-11-15  4:27 UTC (permalink / raw)


"Adam Beneschan" <adam@irvine.com> wrote in message
news:1193674697.257242.163990@v23g2000prn.googlegroups.com...
...
> Other than that, I can see no reason not to use 'Image except
> that perhaps it has been decreed impure by the High Priests of Purity,
> who apparently have determined this in some ritual in which they dance
> around a statue of Ada Lovelace and burn huge listings of C++ code and
> chant some incantation to ask the statue what constructs are
> considered holy and pure.

I think I'll suggest that for the next ARG meeting. It'll break up the
monotony. ;-)

I think I'm going to have a hard time getting that image (pun intended) out
of my mind. Thanks for the laugh!

                              Randy.





^ permalink raw reply	[flat|nested] 56+ messages in thread

end of thread, other threads:[~2007-11-15  4:27 UTC | newest]

Thread overview: 56+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-26 14:58 Real Time IO routines andrew
2007-10-26 16:43 ` Anh Vo
2007-10-26 16:53   ` andrew
2007-10-26 17:04     ` Anh Vo
2007-10-26 17:21       ` andrew
2007-10-26 18:31         ` Anh Vo
2007-10-26 18:36         ` Ludovic Brenta
2007-10-26 20:00           ` andrew
2007-10-26 20:29             ` Ludovic Brenta
2007-10-26 20:46               ` Dmitry A. Kazakov
2007-10-26 20:33             ` Dmitry A. Kazakov
2007-10-26 21:14               ` andrew
2007-10-26 21:54                 ` Anh Vo
2007-10-26 22:34                 ` Adam Beneschan
2007-10-27  1:58                 ` tmoran
2007-10-27 12:40                 ` John McCormick
2007-10-27 20:12                   ` andrew
2007-10-26 17:12 ` Ed Falis
2007-10-27  8:56 ` anon
2007-10-27 10:18   ` Dmitry A. Kazakov
2007-10-27 20:15     ` anon
2007-10-27 20:49       ` Dmitry A. Kazakov
2007-10-27 21:51       ` Simon Wright
2007-10-28 11:35         ` Ludovic Brenta
2007-10-30 14:37           ` Simon Clubley
2007-10-30 13:47             ` Ludovic Brenta
2007-10-30 14:46             ` Jean-Pierre Rosen
2007-10-31 14:38               ` Ada coding standards, was: " Simon Clubley
2007-10-31 18:02                 ` anon
2007-10-31 19:23                   ` Georg Bauhaus
2007-10-31 20:40                   ` John W. Kennedy
2007-11-01 11:27                   ` Stephen Leake
2007-11-01 20:38                     ` anon
2007-10-29 19:28         ` Real Time IO routines -- answering Simon Wright part 1 anon
2007-10-29 21:24           ` Georg Bauhaus
2007-10-29 21:31             ` Georg Bauhaus
2007-10-29 22:01             ` Dmitry A. Kazakov
2007-10-29 22:38           ` Keith Thompson
2007-10-30  0:58             ` tmoran
2007-10-30 16:35         ` Real Time IO routines answering Simon Wright part 2 anon
2007-10-30 21:50           ` Simon Wright
2007-10-31 15:35           ` Adam Beneschan
2007-10-31 20:08             ` anon
2007-10-31 21:08               ` Georg Bauhaus
2007-10-31 21:42               ` Markus E L
2007-11-01  1:00               ` Adam Beneschan
2007-10-28  1:15       ` Real Time IO routines Jeffrey Creem
2007-10-29 16:18       ` Adam Beneschan
2007-10-29 16:40         ` Robert A Duff
2007-10-29 17:26           ` Adam Beneschan
2007-10-29 22:34             ` Keith Thompson
2007-10-29 17:25         ` Jean-Pierre Rosen
2007-11-15  4:27         ` Randy Brukardt
2007-11-15  4:27         ` Randy Brukardt
2007-10-29 18:53       ` andrew
2007-10-29 22:35         ` Keith Thompson

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