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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,a90718b61c5de714 X-Google-Attributes: gid103376,public From: dewar@merv.cs.nyu.edu (Robert Dewar) Subject: Re: assignments using different types Date: 1997/01/29 Message-ID: #1/1 X-Deja-AN: 213027307 references: <32EE4431.6D24@ti.com> organization: New York University newsgroups: comp.lang.ada Date: 1997-01-29T00:00:00+00:00 List-Id: 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;