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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1dd28d5040ded1f8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-16 06:54:12 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!logbridge.uoregon.edu!hammer.uoregon.edu!skates!not-for-mail From: Stephen Leake Newsgroups: comp.lang.ada Subject: Re: Announce: Grace project site operational Date: 16 May 2002 09:44:17 -0400 Organization: NASA Goddard Space Flight Center (skates.gsfc.nasa.gov) Message-ID: References: <3CD88FBD.4070706@telepath.com> <3CD91E31.1060004@telepath.com> <3CDBD673.FF452A3D@otelco.net> <4519e058.0205140718.3ddb1b2a@posting.google.com> NNTP-Posting-Host: anarres.gsfc.nasa.gov Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: skates.gsfc.nasa.gov 1021557080 5370 128.183.220.71 (16 May 2002 13:51:20 GMT) X-Complaints-To: usenet@news.gsfc.nasa.gov NNTP-Posting-Date: 16 May 2002 13:51:20 GMT User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:24193 Date: 2002-05-16T13:51:20+00:00 List-Id: "Marin David Condic" writes: > Think about why it is that Ada provides separate types with strong rules > about separate-but-equal treatment of them. Its about keeping things > separate that belong separate. So you need to ask the question "Should these > things (almost) never be mixed or confused with each other?" In my > produce-inventory-program I (almost) never have a good reason to mix up a > count of apples with a count of oranges - hence the archetypical example. True. > But if you're doing computations with velocities and accelerations > and such, then you thoroughly intend to mix them and you are then > saying "I'm dealing with general mathematical relationships between > one thing and another" That sort of calls for a common type of > sufficient size to support the anticipated calculations. After all, > the common object of interest here is the "mathematical > relationship", not the not the particular items in some specific > engineering units. Not quite true. For me, the point of having Ada "do units right" is to catch errors. For example, Newton's second law is F = m a. F is in kg-m/s^2, m is in kg, a is in m/s^2. If I accidently code this as: Force := Mass / Acceleration; I'd like the compiler to say "hey, you got the units wrong". > I agree that a good compromise is to have subtypes that can then be > freely mixed with possible constraints as needed. This provides you > with some ability to distinguish in your code where you are dealing > with one thing versus another (velocities versus accelerations) and > have the values sanity checked by your constraints, while leaving > you the ability to freely mix the math operations. For me, subtypes are like comments; they can help, but they can also mislead. In physical systems, it is often more of a nuisance to have constraints. > Of course, this doesn't save you from everything - e.g. passing a > velocity to a function that needs an acceleration - but you just > can't always have absolute safety. An automatically generated Ada package with _all_ the necessary types would give you full unit checking. So do the C++ templates. > Absolute safety is for people who don't have the balls to live in > the real world. :-) I agree with this principle in general, but in this case it doesn't apply :). -- -- Stephe