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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,9d303864ae4c70ad X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2004-04-11 09:06:00 PST Path: archiver1.google.com!news1.google.com!news.glorb.com!cyclone1.gnilink.net!spamkiller2.gnilink.net!gnilink.net!nwrdny03.gnilink.net.POSTED!0e8a908a!not-for-mail From: Hyman Rosen User-Agent: Mozilla Thunderbird 0.5 (Windows/20040207) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Expressing physical units References: <5ad0dd8a.0404090512.15af2908@posting.google.com> <5ad0dd8a.0404100507.729d3577@posting.google.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Date: Sun, 11 Apr 2004 16:05:59 GMT NNTP-Posting-Host: 68.237.203.59 X-Complaints-To: abuse@verizon.net X-Trace: nwrdny03.gnilink.net 1081699559 68.237.203.59 (Sun, 11 Apr 2004 12:05:59 EDT) NNTP-Posting-Date: Sun, 11 Apr 2004 12:05:59 EDT Xref: archiver1.google.com comp.lang.ada:6982 Date: 2004-04-11T16:05:59+00:00 List-Id: Jacob Sparre Andersen wrote: > I don't understand C++ templates well enough to be able to see if it > is realistic to copy enough of it to Ada, to allow the easier handling > of compile-time unit checking available in C++. I am afraid it would > give too many unwanted possibilities in Ada, but it is very tempting. The main problem with adopting this feature in Ada is Ada's lack of automatic instantiation of generics. This arises in the multiplicative operators. If you look at how I wrote operator*, you'll see that it synthesizes a return type by adding the corresponding template parameters of the operands. In use, you simply multiply a pair of units together and the result has the correct type and can participate in further operations. The MACKS package that people talk about here uses the same techniques to represent units without overhead, but it does a whole bunch of explicit instantiations to make them ready for use. If it happens to miss some needed versions, it needs to be reconfigured to generate them.