From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,b1850e397df49d95 X-Google-Attributes: gid103376,public From: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: How to convert an Fixed_Point to to an Integer ? Date: 1996/12/24 Message-ID: #1/1 X-Deja-AN: 205791065 references: <01bbf058$cbdbf980$LocalHost@jerryware> <1996Dec23.072835.1@eisner> <01bbf179$0c4361e0$9b2d5c8b@jerryware> organization: New York University newsgroups: comp.lang.ada Date: 1996-12-24T00:00:00+00:00 List-Id: Jerry van Dijk said Hmmmm, I don't know. The idea behind encapsulation is protecting the client code against changes in implementation, not preventing anyone to assign the number of seconds since the epoch to an Integer :-) You are confused. The notion of time has nothing whatsoever to do with the epoch which is a unix specific notion that might or might not have something to do with the implementation of Time. The proper way to get the number of seconds from the epoch to now is Integer (Calendar.Clock - Epoch_Time); where Epoch_Time is a constant declared as something like Epoch_Time : constant Time := Calendar.Time_Of (1970,1,1,0.0); This approach is clean, and correct Ada and completely portable. Why would you want to consider anything else. As I said before you have lead yourself astray looking at the private part of Calendar. So I solved it by putting these conversion operation in a child of Ada.Calender: YECH! A horrible solution, which is completely non-portable. Implementations do not have to permit you to compile grand-children of Ada, and indeed, GNAT does NOT permit you to do so. Yes, you can use the switch -gnatg to compile such a unit, but as soon as you use -gnatg, you no longer have correct Ada 95 compiler semantics, the -gnatg switch is definitely intended only for implementors! The conversions you are looking for make no sense in the general case, and the operations in your Posix child are very implemenbtation specific, and have no business being a child of Calendar in any case. It is perfectly reasonable to implement this package without any access to the private part of Calendar as a separate user level package, and that is what you should do! P.S. can you try to keep your lines to 80 chars, thanks