comp.lang.ada
 help / color / mirror / Atom feed
* Re: Constants of type Calendar.Time (?)
@ 1993-04-17 19:54 Michael Feldman
  0 siblings, 0 replies; only message in thread
From: Michael Feldman @ 1993-04-17 19:54 UTC (permalink / raw)


In article <WOODRUFF.93Apr15124008@EC2226.addvax.llnl.gov> WOODRUFF@EC2226.addv
ax.llnl.gov writes:
>Suppose I am using calendar.time as a field in a database, and I wish 
>to provide a procedure for retrieving some elements from the database
>keyed by time.  I might provide a function
>
>FUNCTION Get (Starting_At  : IN Calendar.Time := Prehistory)  
>              RETURN Array_Of_Results ;
>
>Or, I might want to make a function that returns the MOST RECENT data:
>
>FUNCTION Get (Up_Until  : IN Calendar.Time  := Now)
>              RETURN Array_Of_Results ;
>
>Can someone suggest how I can construct a constant of the type Time which
>I could recognize in the BODY of Get, and resolve my data search at run time 
>with a value that I obtain from Calendar.Clock when the search begins?
>
>>>  Just to clarify my wish, I would do the following except for the blatant
>    illegality of the type mismatch:  
>    FUNCTION Get (Up_Until  : IN Calendar.Time  := 0)  RETURN Array_Of_Results
 ;
>
All your examples look fine to me; they are all default parameter values.
The only problem is, as you pointed out, the type mismatch in the last one.

I suggest defining a named constant whose value is the beginning of Time, then
using it wherever needed:

   BeginningOfTime: CONSTANT Calendar.Time :=
     Calendar.Time_Of(Month => 1, Day => 1, Year => 1901, Seconds => 0.0);

Since Seconds will default to 0.0, its presence here is just for clarity, as
is the named association, which you can omit if you choose.

I think the point you were after was how to make a constant of Time value;
becauswe Time is private you must use the constructor Time_Of or the
current-time function Clock, or another Time-returning Calendar operation.

Cheers -

Mike Feldman
------------------------------------------------------------------------
Michael B. Feldman
co-chair, SIGAda Education Committee

Professor, Dept. of Electrical Engineering and Computer Science
School of Engineering and Applied Science
The George Washington University
Washington, DC 20052 USA
(202) 994-5253 (voice)
(202) 994-5296 (fax)
mfeldman@seas.gwu.edu (Internet)

"The most important thing is to be sincere, 
and once you've learned how to fake that, you've got it made." 
-- old show-business adage
------------------------------------------------------------------------

^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~1993-04-17 19:54 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1993-04-17 19:54 Constants of type Calendar.Time (?) Michael Feldman

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