comp.lang.ada
 help / color / mirror / Atom feed
From: "Matthew Heaney" <mheaney@banet.net>
Subject: Re: Operators -> unit analysis
Date: 2000/01/05
Date: 2000-01-05T00:00:00+00:00	[thread overview]
Message-ID: <3873a69a_1@news1.prserv.net> (raw)
In-Reply-To: 387383D0.4EA02E95@earthlink.net

In article <387383D0.4EA02E95@earthlink.net> , Charles Hixson 
<charleshixsn@earthlink.net>  wrote:

> And some good way to handle units.  So that we could safely say things like:
>
>      speed := 37.miles / 1.5.hours;
> I'm not too pleased with the syntax, but the idea is there.

You can already do this:

  Speed := Miles'(37.0) / Hours'(1.5);

I always recommend type qualification for literals when units are an
issue.

> I dislike the syntax:
>     speed := (37 * mile) / (1.5 * hour);
> though I prefer it to:
>     speed := miles (37) / hours (1.5);
> but that's the best that I know how to do it in Ada.  Is there a better
> choice?  (I.e. one that would look more like what a math student would write
> in a word problem?)

See above.


> Of course one could say:
>     dist    :    constant Miles    :=    37;
>     time   :    constant Hours    :=   1.5;
>     speed :  MpH;
>     speed    :=    dist / time;
>
> but that seems quite unnecessarily verbose!

Agreed.




  reply	other threads:[~2000-01-05  0:00 UTC|newest]

Thread overview: 77+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-12-23  0:00 Ada Brijesh
1999-12-23  0:00 ` Ada reason67
1999-12-23  0:00   ` Ada Robert Dewar
2000-01-03  0:00     ` Ada Terry Sikes
2000-01-03  0:00       ` Ada Hyman Rosen
2000-01-04  0:00         ` Ada Florian Weimer
2000-01-04  0:00           ` Ada Hyman Rosen
2000-01-04  0:00           ` Ada Brian Rogoff
2000-01-04  0:00         ` Ada Robert Dewar
2000-01-04  0:00           ` Ada Robert A Duff
2000-01-04  0:00             ` Ada Hyman Rosen
2000-01-04  0:00           ` Ada Hyman Rosen
2000-01-04  0:00         ` Ada Richard D Riehle
2000-01-04  0:00           ` Ada Hyman Rosen
2000-01-04  0:00             ` Ada Richard D Riehle
2000-01-04  0:00             ` Ada Robert A Duff
2000-01-04  0:00         ` Ada Terry Sikes
2000-01-05  0:00           ` Operators -> unit analysis Charles Hixson
2000-01-05  0:00             ` Matthew Heaney [this message]
2000-01-05  0:00               ` Charles Hixson
2000-01-05  0:00             ` Ted Dennison
2000-01-06  0:00               ` Samuel T. Harris
2000-01-07  0:00                 ` Robert Dewar
2000-01-07  0:00                   ` Robert A Duff
2000-01-07  0:00                     ` Matthew Heaney
2000-01-08  0:00                       ` Robert Dewar
2000-01-08  0:00                         ` Robert A Duff
2000-01-10  0:00                       ` Operator precedence--was " Howard W. LUDWIG
2000-01-14  0:00                         ` Mark A Biggar
2000-01-07  0:00                   ` Ted Dennison
2000-01-07  0:00                     ` Brian Rogoff
2000-01-06  0:00               ` Charles Hixson
2000-01-05  0:00             ` Pat Rogers
2000-01-05  0:00               ` Charles Hixson
2000-01-05  0:00             ` Hyman Rosen
2000-01-05  0:00               ` Matthew Heaney
2000-01-06  0:00             ` Robert Dewar
2000-01-06  0:00               ` Terry Sikes
2000-01-06  0:00                 ` Robert A Duff
2000-01-07  0:00                   ` Terry Sikes
2000-01-07  0:00                     ` Brian Rogoff
2000-01-07  0:00                 ` Ted Dennison
2000-01-07  0:00                   ` Tucker Taft
2000-01-08  0:00                     ` Robert Dewar
2000-01-10  0:00                       ` Tucker Taft
2000-01-10  0:00                         ` Florian Weimer
2000-01-04  0:00       ` Ada Robert Dewar
2000-01-04  0:00         ` Ada Terry Sikes
2000-01-05  0:00           ` Ada Robert Dewar
2000-01-05  0:00             ` Ada Terry Sikes
2000-01-06  0:00           ` Ada Al Christians
2000-01-06  0:00             ` Ada Terry Sikes
2000-01-07  0:00             ` Ada Robert Dewar
1999-12-23  0:00 ` Ada Robert Dewar
1999-12-23  0:00   ` Ada tmoran
1999-12-23  0:00 ` Ada Roger Racine
1999-12-28  0:00   ` Ada Marin D. Condic
1999-12-31  0:00     ` Ada Richard D Riehle
2000-01-02  0:00       ` Ada Marin D. Condic
2000-01-02  0:00         ` Ada Robert Dewar
2000-01-02  0:00           ` Ada Marin D. Condic
2000-01-03  0:00             ` Ada Ted Dennison
2000-01-03  0:00             ` Ada Robert Dewar
2000-01-03  0:00               ` Ada Marin D. Condic
2000-01-03  0:00                 ` Ada Roger Racine
2000-01-03  0:00                 ` Ada Larry Kilgallen
2000-01-04  0:00                   ` Ada Charles Hixson
2000-01-13  0:00     ` Ada Magnus Alexandersson
2000-01-13  0:00     ` Ada Magnus Alexandersson
2000-01-14  0:00       ` Ada Tarjei T. Jensen
2000-01-14  0:00         ` Ada Larry Kilgallen
2000-01-14  0:00           ` Ada Marin D. Condic
2000-01-14  0:00             ` Ada Magnus Alexandersson
2000-01-14  0:00               ` Ada Marin D. Condic
1999-12-23  0:00 ` Ada Jon Jensen
1999-12-23  0:00 ` Ada Greg Martin
  -- strict thread matches above, loose matches on Subject: below --
2000-01-08  0:00 Operators -> Unit Analysis mfeldman
replies disabled

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