comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: GNAT.Sockets: Timeval_Duration is in milliseconds?
Date: Sun, 9 Dec 2007 18:25:01 +0100
Date: 2007-12-09T18:25:04+01:00	[thread overview]
Message-ID: <1cbxsyun6u33d.1ilz0v47jxl1j$.dlg@40tude.net> (raw)
In-Reply-To: 314aea38-7dc1-462e-b272-31817c147996@p69g2000hsa.googlegroups.com

On Sun, 9 Dec 2007 07:55:02 -0800 (PST), gpriv@axonx.com wrote:

> On Dec 9, 4:33 am, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
> wrote:
>> On Sat, 08 Dec 2007 19:45:53 -0600, tmo...@acm.org wrote:
>>>   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.
>>
>> Sorry but this makes no sense. The physical entity being measured is
>> duration T. Gallon is a measure of volume L**3. Clearly T /= L**3. As for
>> seconds, milliseconds, years, centuries etc, all they fall under the
>> category T (duration). They are numbers expressing the *same* physical
>> entity. It is rather instructive to use the same type for them when
>> possible.
> 
> Conceptually you're right, but many annoying bugs are introduced by
> assuming wrong scale when using same entities (feet/meter, T(K)/t(C),
> X/Y/Z coordinates, etc.) In order to make the language work for you
> one should go with different types.  My favorite is X,Y,Z coordinates:
> all measure distance but misinterpreting those may case a trouble.  So
> by introducing the new types for each plus one direction-less Distance
> type will be good safety measure while all three are distance
> entities.

It makes a lot of sense to use distinct types for horizontal and vertical
distances as long no rotation operation is used. I do it too. Similarly it
makes even more sense to distinguish screen coordinates and ones relative
to some window. The same could be true for durations when applied to
different, unsynchronized epochs, for instance.

But all this just does not apply to the case at hand. Because that deals
with exactly the same physical entity as the delay statement does.
Therefore using a separate type is just a bad design that slavishly follows
OS APIs.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2007-12-09 17:25 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-12-08 19:45 GNAT.Sockets: Timeval_Duration is in milliseconds? gpriv
2007-12-08 22:11 ` Simon Wright
2007-12-08 22:34   ` gpriv
2007-12-09  1:45     ` tmoran
2007-12-09  9:33       ` Dmitry A. Kazakov
2007-12-09 12:50         ` Gautier
2007-12-09 13:37           ` Dmitry A. Kazakov
2007-12-09 14:59             ` Martin Krischik
2007-12-09 17:24               ` Dmitry A. Kazakov
2007-12-09 15:55         ` gpriv
2007-12-09 17:25           ` Dmitry A. Kazakov [this message]
2007-12-09 18:26     ` Simon Wright
2007-12-09 19:36       ` gpriv
2007-12-09 22:51         ` Simon Wright
2007-12-09 23:27           ` gpriv
2007-12-10 20:06             ` Simon Wright
2007-12-10 21:02               ` gpriv
2007-12-11 20:33                 ` Simon Wright
2007-12-13  3:44                   ` gpriv
2007-12-13 13:13                     ` Simon Wright
2007-12-13 14:32                       ` gpriv
2007-12-09 19:46       ` tmoran
2007-12-09  9:01   ` Martin Krischik
2007-12-09  9:32 ` Dmitry A. Kazakov
replies disabled

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