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 X-Google-Thread: 103376,9d303864ae4c70ad X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-04-10 06:52:19 PST Path: archiver1.google.com!news1.google.com!news.glorb.com!news.tele.dk!news.tele.dk!small.news.tele.dk!newsfeed.icl.net!newsfeed.fjserv.net!feed.news.tiscali.de!darth-vader.mobilixnet.dk!newsfeed.orangenet.dk!news.hacking.dk!pnx.dk!munin.nbi.dk!not-for-mail From: Jacob Sparre Andersen Newsgroups: comp.lang.ada Subject: Re: Expressing physical units (Was: Reprise: 'in out' parameters for functions) Date: 10 Apr 2004 15:52:14 +0200 Organization: Munin Sender: sparre@sparre.crs4.it Message-ID: References: <5ad0dd8a.0404090512.15af2908@posting.google.com> <5ad0dd8a.0404100507.729d3577@posting.google.com> NNTP-Posting-Host: 80.241.165.32 Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: munin.grove.home 1081605137 30541 80.241.165.32 (10 Apr 2004 13:52:17 GMT) X-Complaints-To: sparre@munin.nbi.dk NNTP-Posting-Date: Sat, 10 Apr 2004 13:52:17 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: archiver1.google.com comp.lang.ada:6950 Date: 2004-04-10T15:52:14+02:00 List-Id: Wojtek Narczynski wrote: > Jacob Sparre Andersen wrote: > > The type system is not _unable_ to express physical units. It > > just has some limitations in how you can do it. > > It depends on how exactly you phrase out the task. If you define it > as having a static check on physical units, I believe Ada type > system is not able to do this. You are left with paper and pencil. One of my programs disagrees somewhat with your statement. I switched from run-time to compile-time checking of unit mismatches, when a recent version of Macks made it practical to start using compile-time checks. It is though correct that physical units are not a specific Ada type, but rather have to be implemented using the basic type system. With a tool like Macks, it is reasonably fast to implement the necessary types for compile-time checking of unit mismatch. Before Macks matured sufficiently, I either used run-time checks or hand-coded the types I needed. > > And although I am annoyed by the limitations, I still haven't seen > > a description of how the language can make it easier, without > > introducing problems outweighing the benefits. I have tried to > > formulate such a modification to Ada myself, but ended up with > > something that appeared to be (provably) impossible to compile. > > (I converged your note here) > > I find this subject fascinating. I remember matchcad doing units > check for me 10 years ago when I was in secondary school, yet I have > not seen any compiler capable of doing the same. I was thinking that > a term rewriting system for partial evaluation of the program would > do the job. Or maybe are there problems with modularization? Could > you point me at your results, if they are public? They are unfortunately not published (and they are written in Danish). Also, I stopped once _I_ was certain it couldn't be done, so I never wrote down a complete proof, but just enough to convince a colleague. It should be noted that my analysis was tied rather strongly to Ada, and a more relaxed programming language might be able to do something that would be sufficiently close to full compile-time unit checking. Are you sure that "matchcad" actually did full compile-time unit checking? Jacob -- �USA fights for the right of the individual.� �Yes. Those of the individual George W. Bush.� -- with thanks to Olfax