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.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,1dd28d5040ded1f8 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-05-15 16:34:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!cpk-news-hub1.bbnplanet.com!news.gtei.net!nntp.abs.net!uunet!dca.uu.net!ash.uu.net!prodigy.com!newsmst01.news.prodigy.com!prodigy.com!postmaster.news.prodigy.com!newssvr14.news.prodigy.com.POSTED!3bae8248!not-for-mail From: tmoran@acm.org Newsgroups: comp.lang.ada Subject: Re: Announce: Grace project site operational References: <3CE15D0A.3050100@mail.com> X-Newsreader: Tom's custom newsreader Message-ID: NNTP-Posting-Host: 67.112.203.7 X-Complaints-To: abuse@prodigy.net X-Trace: newssvr14.news.prodigy.com 1021505623 ST000 67.112.203.7 (Wed, 15 May 2002 19:33:43 EDT) NNTP-Posting-Date: Wed, 15 May 2002 19:33:43 EDT Organization: Prodigy Internet http://www.prodigy.com X-UserInfo1: [[PAPDCAO@SIRQ@[ORHD]_\@VR]^@B@MCPWZKB]MPXHTEPIB_NVUAH_[BL[\IRKIANGGJBFNJF_DOLSCENSY^U@FRFUEXR@KFXYDBPWBCDQJA@X_DCBHXR[C@\EOKCJLED_SZ@RMWYXYWE_P@\\GOIW^@SYFFSWHFIXMADO@^[ADPRPETLBJ]RDGENSKQQZN Date: Wed, 15 May 2002 23:33:43 GMT Xref: archiver1.google.com comp.lang.ada:24135 Date: 2002-05-15T23:33:43+00:00 List-Id: > template > ... The attempt below is is not as nice as "type Velocity is new Float dimension Distance/Time;" and it needs parenthesization, but it works in Ada 95. Each new unit requires a "type unit is " and each legal pair needs two lines: a generic instantiation and a "use". generic type left is digits <>; type right is digits <>; type result is digits <>; package multiply is function "*"(a : left; b : right) return result; function "*"(a : right; b : left) return result; end multiply; package body multiply is function "*"(a : left; b : right) return result is begin return result(float(a)*float(b));end "*"; function "*"(a : right; b : left) return result is begin return result(float(a)*float(b));end "*"; end multiply; generic type left is digits <>; type right is digits <>; type result is digits <>; package ratio is function "/"(a : left; b : right) return result; end ratio; package body ratio is function "/"(a : left; b : right) return result is begin return result(float(a)/float(b));end "/"; end ratio; with Multiply,Ratio; procedure try_d is type Seconds is new Float; type Centimeters is new Float; type Grams is digits 4; type Velocity is new Float; package Centimeters_per_Second is new Ratio(Centimeters, Seconds, Velocity); use Centimeters_per_Second; type Acceleration is new Float; package Velocity_per_Second is new Ratio(Velocity, Seconds, Acceleration); use Velocity_per_Second; type Dynes is new Float; package Grams_Acceleration is new Multiply(Grams, Acceleration, Dynes); use Grams_Acceleration; t : Seconds; d : Centimeters range 0.0 .. 100.0; v : Velocity; m : Grams; a : Acceleration; f : Dynes; x,y,z : Float; begin v := d/t; a := v/t; f := m*a; f := m*(v/t); x := float(d)*float(t); y := d*t; -- line 35, erroneous z := float(d*t); -- line 36, erroneous end try_d; gnatchop/gnatmake gives: gcc -c try_d.adb try_d.adb:35:09: invalid operand types for operator "*" try_d.adb:35:09: left operand has subtype of "centimeters" defined at line 22 try_d.adb:35:09: right operand has type "Seconds" defined at line 5 try_d.adb:36:15: invalid operand types for operator "*" try_d.adb:36:15: left operand has subtype of "centimeters" defined at line 22 try_d.adb:36:15: right operand has type "Seconds" defined at line 5 gnatmake: "try_d.adb" compilation error