comp.lang.ada
 help / color / mirror / Atom feed
From: dewar@merv.cs.nyu.edu (Robert Dewar)
Subject: Re: assignments using different types
Date: 1997/01/29
Date: 1997-01-29T00:00:00+00:00	[thread overview]
Message-ID: <dewar.854546574@merv> (raw)
In-Reply-To: 32EE4431.6D24@ti.com


iDavid asks

"Example:
   type Distance_Type is new float range 0.0 .. 1000.0;
   type Time_Type is new float range 0.0 .. 10.0;
   type Velocity_Type is new float;

   Distance : Distance_Type := 100.0;
   Time     : Time_Type     := 10.0;
   Velocity : Velocity_Type;

...

   -- A difficult to read, but legal Ada assignment.
   Velocity := Velocity_Type(float(Distance) / float(Time));


Can anyone provide me with suggestions to improve the readability
of the above assignment?  Of course, I'd like efficiency to be
similar to that of using the same type for all the variables."

Robert replies

Most certainly: define an approrpiate "/" operator, mark it to be inlined
with pragma Inline, and then just write

  Velocity := Distance / Time;





  parent reply	other threads:[~1997-01-29  0:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-01-28  0:00 assignments using different types David Dessert
1997-01-28  0:00 ` Christopher Green
1997-01-29  0:00 ` Robert Dewar [this message]
1997-01-29  0:00 ` Robert Dewar
1997-01-30  0:00   ` inter-unit inlining (was: Re: assignments using different types) Fergus Henderson
1997-01-29  0:00 ` assignments using different types Robert I. Eachus
1997-01-29  0:00 ` Paul Van Bellinghen
1997-02-10  0:00   ` Robert Dewar
  -- strict thread matches above, loose matches on Subject: below --
1997-01-29  0:00 tmoran
1997-01-30  0:00 Thomas
replies disabled

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