comp.lang.ada
 help / color / mirror / Atom feed
From: progers@acm.org
Subject: Re: Math on dimensioned quantities
Date: 1996/07/09
Date: 1996-07-09T00:00:00+00:00	[thread overview]
Message-ID: <4rui3u$h5b@uuneo.neosoft.com> (raw)
In-Reply-To: 9607091345.AA03915@most


In <9607091345.AA03915@most>, "W. Wesley Groleau (Wes)" <wwgrol@PSESERV3.FW.HAC.COM> writes:
>I once had to design and code capabilities for numeric types with
>dimensions.  Did it two ways: for support code, each number was a record
>with its value and the units (enumerated).  Efficiency was not a problem,
>but the lack of the 'usual' attributes was an irritation.
>
>The deliverable code used derived floats, not for the sake of attributes,
>but because of the (unfounded?) fear of size and time degradation.  What
>turned out to be a nuisance here was redefining all the operators.
>A generic "operator with conversion factor" was easy enough though
>tedious for the legal operations such as
>   "+"(L:feet;R:inch)return inch -> inch(L)*12+R
>Had to instantiate it in the spec in Ada-83, but now it can be
>instantiated in the body and then renamed.
>
>But it was a nuisance to have to declare Units_Mismatch : exception
>and redefine MANY multipliers and dividers to raise it.  [For example
>"*"(L,R:inch)return inch]
>
>Some compilers will warn you "xxx exception will be raised at run-time"
>but it would be a nice language "feature" to extend type checking to
>this.  I realize that for a compiler to know all the options, it would
>also have to know all the units, which is not feasible.  But--compiler
>writers listening?--how about a pragma similar to
>
>   pragma Disallow ( Operation => "*", For_Type => Inch );
>
>If I'm repeating anyone (I don't get "Ada Letters") please forgive me.


You could make those undesirable operations abstract, which
would make them uncallable....


>
>
>---------------------------------------------------------------------------
>W. Wesley Groleau (Wes)                                Office: 219-429-4923
>Magnavox - Mail Stop 10-40                               Home: 219-471-7206
>Fort Wayne,  IN   46808              elm (Unix): wwgrol@pseserv3.fw.hac.com
>---------------------------------------------------------------------------



pat
---------------
Patrick Rogers
progers@acm.org





  reply	other threads:[~1996-07-09  0:00 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1996-07-09  0:00 Math on dimensioned quantities W. Wesley Groleau (Wes)
1996-07-09  0:00 ` progers [this message]
1996-07-10  0:00 ` Robert A Duff
1996-07-10  0:00   ` progers
1996-07-10  0:00   ` Jon S Anthony
1996-07-10  0:00     ` Robert A Duff
1996-07-10  0:00       ` Robert Dewar
1996-07-11  0:00         ` Dale Stanbrough
replies disabled

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