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,cc4f25d878383cc X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2001-12-03 09:04:58 PST Path: archiver1.google.com!news1.google.com!sn-xit-02!supernews.com!newsfeed.direct.ca!look.ca!btnet-peer0!btnet!news5-gui.server.ntli.net!ntli.net!news2-win.server.ntlworld.com.POSTED!not-for-mail From: "chris.danx" Newsgroups: comp.lang.ada References: <3C0A5054.E74A82E7@worldnet.att.net> Subject: Re: Another Idea for Ada 20XX X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2600.0000 X-MIMEOLE: Produced By Microsoft MimeOLE V6.00.2600.0000 Message-ID: <8cOO7.1324$H4.241179@news2-win.server.ntlworld.com> Date: Mon, 3 Dec 2001 17:00:28 -0000 NNTP-Posting-Host: 62.253.12.160 X-Complaints-To: abuse@ntlworld.com X-Trace: news2-win.server.ntlworld.com 1007398788 62.253.12.160 (Mon, 03 Dec 2001 16:59:48 GMT) NNTP-Posting-Date: Mon, 03 Dec 2001 16:59:48 GMT Organization: ntlworld News Service Xref: archiver1.google.com comp.lang.ada:17350 Date: 2001-12-03T17:00:28+00:00 List-Id: "Mark Lundquist" wrote in message news:KoMO7.2339$Px.45566@rwcrnsc54... > > Yes. Units do need to be primitive. > > I've been thinking about this for a while too, but haven't had the chance to > write it up. The idea frankly never occurred to me until Ehud suggested it > in a post a few months back. At first I thought "that's nuts". But it > isn't :-)... > > We now have type-safe programming in Ada. But there are two things wanting: > (1) unit-safe programming, and (2) automatic unit conversion. These cannot > be provided without augmenting the language. (Note: "automatic" does not > mean "implicit", it means the compiler does the work for you). > > This would really complete Ada's support for scalar abstraction. > > "James Rogers" wrote in message > news:3C0A5054.E74A82E7@worldnet.att.net... > > > [snip...] > > > > Possible declarative syntax might be: > > > > type Meters is unit range (0.0..1.0E380); > > type Hours is unit range (0.0..9.99E30); > > Something like that. I don't think this is going to cut it, but you're on > the right track.... Unit declarations need to be independent of types. > Then a dimensioned type would be created by combining a unit with a > representation later on, in the type definition. You need to defer the > "binding" of a type to a unit in order to achieve the right level of > abstraction. > > type Speed is unit(Meters / Hours); > > I think the correct approach would involve declaring a unit (but not a type) > in terms of Meters and Hours (in your example). The programmer would want > to call this unit "Meters_Per_Hour", not "Speed".