From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.5-pre1 (2020-06-20) on ip-172-31-74-118.ec2.internal X-Spam-Level: X-Spam-Status: No, score=-1.9 required=3.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.5-pre1 Date: 17 Apr 93 19:54:14 GMT From: seas.gwu.edu!mfeldman@uunet.uu.net (Michael Feldman) Subject: Re: Constants of type Calendar.Time (?) Message-ID: <1993Apr17.195414.7527@seas.gwu.edu> List-Id: In article 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 ------------------------------------------------------------------------