comp.lang.ada
 help / color / mirror / Atom feed
From: Ted Dennison<dennison@telepath.com>
Subject: Re: Unchecked_Conversion
Date: Mon, 11 Jun 2001 13:56:13 GMT
Date: 2001-06-11T13:56:13+00:00	[thread overview]
Message-ID: <164V6.3802$pb1.139228@www.newsranger.com> (raw)
In-Reply-To: 41F37C284A6DE8C0.8A6A99719FF11B52.8149DC60E20677C9@lp.airnews.net

In article <41F37C284A6DE8C0.8A6A99719FF11B52.8149DC60E20677C9@lp.airnews.net>,
Robert B. Love  says...
>
>In <LdLT6.2225$bA3.107918@www.newsranger.com> Ted Dennison wrote:
>> Just to back up Marc here, you should almost *never* have to convert 
>types. The
>> only times I ever have to do it are when interfacing with external 
>routines that
>
>My experience runs counter to this.  My employer has chosen to use
>typing for every conceivable measurement. So we have type Meters, 
>Meters_Per_Second, Feet, Feet_Per_Second, Seconds, Watts, Volts, and so 
>on.
>The list is endless.


I'm sorry. There was an implied "with unchecked_conversion" in there. I often
perform type conversions between numeric types or derived types.

As for the particular (quite different) issue you are talking about: I've worked
with various groups that had to deal with engineering units, and they all tend
towards the same conclusion. You can either use "integer" and "float" for
everything, or you can make a separate type for each and every unit and
intermediate unit you will ever need, along with your own overloaded operators
for every operation that you will ever perform on any combination of them. Any
wishy-washyness in the middle just causes headaches of the kind you have
described.

As the "separate type for everything" route is almost always prohibitive,
usually folks opt for the minimalist route. Of course it can still be a good
idea to use constrained subtypes, esp. for routine interfaces. There can also be
a case for making separate types in certain cases where you want something
special done and don't mind rewriting all the operators to work with integer or
float to achieve that goal (eg: a Degrees type that automaticly does a "mod 360"
on any operator result).

---
T.E.D.    homepage   - http://www.telepath.com/dennison/Ted/TED.html
          home email - mailto:dennison@telepath.com



  parent reply	other threads:[~2001-06-11 13:56 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-06-07  7:46 Unchecked_Conversion Lele
2001-06-07 12:50 ` Why not try Checked_Conversion? Petter Fryklund
2001-06-07 13:01 ` Unchecked_Conversion Marc A. Criley
2001-06-07 13:21 ` Unchecked_Conversion Ted Dennison
2001-06-10 18:20   ` Unchecked_Conversion Robert B. Love 
2001-06-10 19:48     ` Unchecked_Conversion Jeff Creem
2001-06-10 22:10     ` Unchecked_Conversion Keith Thompson
2001-06-11 13:56     ` Ted Dennison [this message]
2001-06-11 14:21     ` Unchecked_Conversion Marin David Condic
2001-06-07 14:01 ` Unchecked_Conversion Jacob Sparre Andersen
2001-06-07 19:44 ` Unchecked_Conversion tmoran
2001-06-09 17:07   ` Unchecked_Conversion Robert A Duff
  -- strict thread matches above, loose matches on Subject: below --
1992-01-02  6:09 unchecked conversion Robert I. Eachus
1991-12-31 13:53 Jean-Pierre Rosen
1991-12-30 23:25 Greg Lomow
replies disabled

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