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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,8ee4430d1820a774 X-Google-Attributes: gid103376,public,usenet X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local01.nntp.dca.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Sat, 08 Dec 2007 19:45:53 -0600 From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: GNAT.Sockets: Timeval_Duration is in milliseconds? References: <99906a58-2645-4880-bd13-9b63a30ffb59@e4g2000hsg.googlegroups.com> X-Newsreader: Tom's custom newsreader Message-ID: Date: Sat, 08 Dec 2007 19:45:53 -0600 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 24.4.252.232 X-Trace: sv3-wmXSlC8SBLpHoq5r56wlTRPm3ybc6AYvYTJOGYPtQAW/hKi6YQACBVjdkboy2m6TQ4ZeYLu17T+84XI!rh7oy8o5sdmtCfUWp8WBrJTzt/vhXVDW4tGm8wl5C2KWoVWCdx2p6noObxuc0GPS4hzjwgwfw4x+!oFB60nejHD+uHjG/0btKKTwHQ+YJ X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.36 Xref: g2news1.google.com comp.lang.ada:18794 Date: 2007-12-08T19:45:53-06:00 List-Id: > But that was precisely my point to rather make a new type instead of > subtyping, since scales are totally different. But that is subjective > I guess. The Ada 95 LRM 9.6(7) says "...; a value of type Duration is used to represent the length of an interval of time, expressed in seconds." It would be bad practice to use a value of type Duration to represent, say, the number of gallons of gasoline remaining, and it would be even worse, because even more confusing, to use it to represent a number of milliseconds. >> Forever : constant := Duration (Integer'Last) * 1.0; Is that legal Ada? Something like Forever : constant := Integer'last * 1.0; or Forever : constant Duration := Integer'last * 1.0; or Forever : constant Duration := Duration(Integer'last); would seem preferable. (It should probably use Interfaces.C.Int'Last instead of Integer'Last, and if Interfaces.C.Int is 64 bits that would probably give a compile time warning.) > -- Timeval_Duration is a subtype of Standard.Duration because the full > -- range of Standard.Duration cannot be represented in the equivalent C > -- structure. >... > Forever : constant := Duration (Integer'Last) * 1.0; > > subtype Timeval_Duration is Duration range Immediate .. Forever; If the code is going to multiply by 1000 to convert milliseconds to integers to put into the C structure, then of course it should be Forever : constant Duration := Duration(Integer'last)/1000;