comp.lang.ada
 help / color / mirror / Atom feed
* Looking for book on Ada Standard Library
@ 2000-09-07  3:30 David Starner
  2000-09-09  1:42 ` Robert Dewar
  0 siblings, 1 reply; 5+ messages in thread
From: David Starner @ 2000-09-07  3:30 UTC (permalink / raw)


I own Barnes' "Programming in Ada 95", but I find its information on
the standard library to be fairly limited. Is there another book
that has more detailed information on the library, or should I just
hunt down a printed version of the AARM?

-- 
David Starner - dstarner98@aasaa.ofe.org
http/ftp: dvdeug.dhis.org
I knew all of the floors in my high school, and none of the ceilings.
	- Chris Painter



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

* Re: Looking for book on Ada Standard Library
  2000-09-07  3:30 Looking for book on Ada Standard Library David Starner
@ 2000-09-09  1:42 ` Robert Dewar
  2000-09-09  4:47   ` DuckE
  0 siblings, 1 reply; 5+ messages in thread
From: Robert Dewar @ 2000-09-09  1:42 UTC (permalink / raw)


In article <8p7247$8q61@news.cis.okstate.edu>,
  dstarner98@aasaa.ofe.org wrote:
> I own Barnes' "Programming in Ada 95", but I find its
information on
> the standard library to be fairly limited. Is there another
book
> that has more detailed information on the library, or should I
just
> hunt down a printed version of the AARM?


The plain old RM is quite adequate for most purposes. This
is actually the most readable part of the RM. For those of
you who can only understand things if you see implementation
code, the GNAT sources can be helpful :-)


Sent via Deja.com http://www.deja.com/
Before you buy.



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

* Re: Looking for book on Ada Standard Library
  2000-09-09  1:42 ` Robert Dewar
@ 2000-09-09  4:47   ` DuckE
  2000-09-09 15:42     ` peter
  0 siblings, 1 reply; 5+ messages in thread
From: DuckE @ 2000-09-09  4:47 UTC (permalink / raw)


I started trying to put together a somewhat verbose description of each
library module.  I haven't gone very far (Im only through part of the
Ada.Calendar package).  You can see my descriptions below.

I started this because in my opinion this is one of the areas in which Ada
is lacking.  Even though Ada code is quite readable it is still code.

I recall seeing some library documentation where each function and data type
was clearly explained and given an example of use.  I have not seen this
kind of documentation recently for any language.

Personally I use Appendix A of the LRM to learn about the standard library
and often wind up writing a small test program to figure out how things
"really" work.

Maybe I'll continue on this project some time.

Sample:
==========================================================
Ada.Calendar

Package Overview
  The Calendar package defines the abstract type "Time" containing an
  implementation specific representation of an absolute time.  This
  package is normally used for functions relating to time of day
  where timing is not critical.  For critical see the package
  Ada.Real_Time.

  Functions are provided for addition and subtraction of "Duration"
  values and for determining a duration as a difference of time values.

  Procedures are provided for breaking the time value into year, month,
  day and second, and for converting a combination of year, month, day
  and seconds of duration to a time value.

  Types for year, month and day are defined as subtypes of integer.

  The type Day_Duration is defined as a subtype of Duration that contains
  one day.

Package Specification (From LRM)

package Ada.Calendar is

   type Time is private;

   subtype Year_Number  is Integer range 1901 .. 2099;
   subtype Month_Number is Integer range 1 .. 12;
   subtype Day_Number   is Integer range 1 .. 31;

   subtype Day_Duration is Duration range 0.0 .. 86_400.0;

   function Clock return Time;

   function Year    (Date : Time) return Year_Number;
   function Month   (Date : Time) return Month_Number;
   function Day     (Date : Time) return Day_Number;
   function Seconds (Date : Time) return Day_Duration;

   procedure Split
     (Date    : Time;
      Year    : out Year_Number;
      Month   : out Month_Number;
      Day     : out Day_Number;
      Seconds : out Day_Duration);

   function Time_Of
     (Year    : Year_Number;
      Month   : Month_Number;
      Day     : Day_Number;
      Seconds : Day_Duration := 0.0)
      return    Time;

   function "+" (Left : Time;     Right : Duration) return Time;
   function "+" (Left : Duration; Right : Time)     return Time;
   function "-" (Left : Time;     Right : Duration) return Time;
   function "-" (Left : Time;     Right : Time)     return Duration;

   function "<"  (Left, Right : Time) return Boolean;
   function "<=" (Left, Right : Time) return Boolean;
   function ">"  (Left, Right : Time) return Boolean;
   function ">=" (Left, Right : Time) return Boolean;

   Time_Error : exception;

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

------------------------------------------------------------------
Function: Clock
Package:  Ada.Calendar
Description:
  The "Clock" function returns a value of type Ada.Calendar.Time
reflecting the current time of day.

Prototype:

   function Clock return Time;

Program Example:

  WITH Ada.Calendar;
  WITH Ada.Text_Io;

  PROCEDURE Clock_Demo IS

    current_time : Ada.Calendar.Time;

  BEGIN
    current_time := Ada.Calendar.Clock;
    -- ...
    DECLARE
      year    : Ada.Calendar.Year_Number;
      month   : Ada.Calendar.Month_Number;
      day     : Ada.Calendar.Day_Number;
      seconds : Ada.Calendar.Day_Duration;
    BEGIN
      Ada.Calendar.Split
        ( Date    => current_time,
          Year    => year,
          Month   => month,
          Day     => day,
          Seconds => seconds );
      Ada.Text_Io.Put_Line( "Year:    " &
da.Calendar.Year_Number'IMAGE( year ) );
      Ada.Text_Io.Put_Line( "Month:   " &
da.Calendar.Month_Number'IMAGE( month ) );
      Ada.Text_Io.Put_Line( "Day:     " &
Ada.Calendar.Day_Number'IMAGE( day ) );
      Ada.Text_Io.Put_Line( "Seconds: " &
da.Calendar.Day_Duration'IMAGE( seconds ) );
    END;
  END Clock_Demo;

Output:
  Year:     2000
  Month:    8
  Day:      23
  Seconds:  76461.552700875
------------------------------------------------------------------
Function: Year
Package:  Ada.Calendar
Description:
  Given a value of type Ada.Calendar.Time returns the year in
  which the time value occurs.

Prototype:

  function Year(Date : Time) return Year_Number;

Program Example:
  WITH Ada.Calendar;
  WITH Ada.Text_Io;

  PROCEDURE Year_Demo IS

    current_time : Ada.Calendar.Time;

  BEGIN
    current_time := Ada.Calendar.Clock;
    -- ...
    DECLARE
      year_value    : Ada.Calendar.Year_Number;
    BEGIN
      year_value := Ada.Calendar.Year( current_time );
      Ada.Text_Io.Put_Line( "Year:    " &
da.Calendar.Year_Number'IMAGE( year_value ) );
    END;
  END Year_Demo;

Output:
  Year:     2000
------------------------------------------------------------------
Function: Month
Package:  Ada.Calendar
Description:
  Given a value of type Ada.Calendar.Time returns the month in
  which the time value occurs.

Prototype:

   function Month   (Date : Time) return Month_Number;

Program Example:
  WITH Ada.Calendar;
  WITH Ada.Text_Io;

  PROCEDURE Month_Demo IS

    current_time : Ada.Calendar.Time;

  BEGIN
    current_time := Ada.Calendar.Clock;
    -- ...
    DECLARE
      month_value   : Ada.Calendar.Month_Number;
    BEGIN
      month_value := Ada.Calendar.Month( current_time );
      Ada.Text_Io.Put_Line( "Month:" &
da.Calendar.Month_Number'IMAGE( month_value ) );
    END;
  END Month_Demo;

Output:
  Month: 8
------------------------------------------------------------------
Function: Day
Package: Ada.Calendar
Description:
  Given a value of type Ada.Calendar.Time returns the day of the
  month in which the time value occurs.

Prototype:

   function Day     (Date : Time) return Day_Number;

Program Example:
  WITH Ada.Calendar;
  WITH Ada.Text_Io;

  PROCEDURE Day_Demo IS

    current_time : Ada.Calendar.Time;

  BEGIN
    current_time := Ada.Calendar.Clock;
    -- ...
    DECLARE
      day_value : Ada.Calendar.Day_Number;
    BEGIN
      day_value := Ada.Calendar.Day( current_time );
      Ada.Text_Io.Put_Line( "Day:" &
da.Calendar.Day_Number'IMAGE( day_value ) );
    END;
  END Day_Demo;

Output:
  Day: 23
------------------------------------------------------------------






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

* Re: Looking for book on Ada Standard Library
  2000-09-09  4:47   ` DuckE
@ 2000-09-09 15:42     ` peter
  2000-09-09 20:16       ` Robert Dewar
  0 siblings, 1 reply; 5+ messages in thread
From: peter @ 2000-09-09 15:42 UTC (permalink / raw)


In article <jhju5.61990$Ur3.756531@news1.sttls1.wa.home.com>, "DuckE" says...
>
 
>I recall seeing some library documentation where each function and data type
>was clearly explained and given an example of use.  I have not seen this
>kind of documentation recently for any language.
>
 
Sun has made a good job in documenting Java classes. See the 'Java class
libraries' books by Cha,Lee. Each Java class is described, with code usage
examples. Each method is describes, and some with examples there as well.

C++ does not even anything like that. 

peter




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

* Re: Looking for book on Ada Standard Library
  2000-09-09 15:42     ` peter
@ 2000-09-09 20:16       ` Robert Dewar
  0 siblings, 0 replies; 5+ messages in thread
From: Robert Dewar @ 2000-09-09 20:16 UTC (permalink / raw)


In article <8pdlpj$1a6i@drn.newsguy.com>,
  peter@nospammail wrote:

> Sun has made a good job in documenting Java classes. See the
> 'Java class libraries' books by Cha,Lee. Each Java class is
> described, with code usage examples. Each method is describes,
> and some with examples there as well.

Probably the thing that helps most people is examples, since
a lot of people prefer to learn by example [personally I find
examples annoying, either they are redundant, in which case
what's the point? or they are essential, in which case you
end up trying to guess general rules by looking at specific
examples, but I quite understand that many people have an
easier time learning from examples than from complete
descriptions.]

So I would think that a systematic set of examples of the use
of the Annex A functionalities would be a useful project to
many people.



Sent via Deja.com http://www.deja.com/
Before you buy.



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

end of thread, other threads:[~2000-09-09 20:16 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2000-09-07  3:30 Looking for book on Ada Standard Library David Starner
2000-09-09  1:42 ` Robert Dewar
2000-09-09  4:47   ` DuckE
2000-09-09 15:42     ` peter
2000-09-09 20:16       ` Robert Dewar

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