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,f5de0f20558e30f2 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-14 13:13:00 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!nntp.abs.net!uunet!dca.uu.net!ash.uu.net!spool0900.news.uu.net!reader0901.news.uu.net!not-for-mail Date: Tue, 14 Jan 2003 16:12:58 -0500 From: Hyman Rosen User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.3a) Gecko/20021212 X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Implicit Instantiations - was: Re: Why is Ada NOT a good choice for a beginner to programming? References: <3E23A88A.2C0969B0@adaworks.com> In-Reply-To: <3E23A88A.2C0969B0@adaworks.com> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Organization: KBC Financial Products Message-ID: <1042578778.223719@master.nyc.kbcfp.com> Cache-Post-Path: master.nyc.kbcfp.com!unknown@nightcrawler.nyc.kbcfp.com X-Cache: nntpcache 3.0.1 (see http://www.nntpcache.org/) NNTP-Posting-Host: 204.253.250.10 X-Trace: 1042578779 reader1.ash.ops.us.uu.net 17827 204.253.250.10 Xref: archiver1.google.com comp.lang.ada:33016 Date: 2003-01-14T16:12:58-05:00 List-Id: Richard Riehle wrote: > Implicit type conversions, along with implicit type promotions run > counter to the Ada philosophy. True, but irrelevant to the Unit C++ code, which does not involve any implicit type conversions. (I should have declared my constructors explicit, and special-cased Unit to allow an implicit conversion from Type. But my example was just a rough outline.) > C++ does not provide the same kind of capability for declaring new > numeric types one has in Ada. This, in spite of the entertaining > example from Mr. Rosen. But it does have the capability for declaring new class types, and that's what the Unit code uses. > Typedef does not do the same thing. We are still left with predefined > types. I was typedefing class types, not numeric types. My typedefs were just mnemonic shorthand for the full Unit<...> types. > The whole idea of Ada is to declare types so they will be checked by > the compiler and so mismatches will be caught. If there is a problem > with that, in the current standard, it needs to be fixed, but implicit > conversions or promotions is simply a bad idea for this language. And that is precisely what the C++ code is doing. At compile time, and with zero run-time size or space overhead, the compiler will catch attempts to add or subtract mismatched units, or to assign one unit type to a different one. Multiplication or division of units automatically produces a correct result type, and you can have arbitrarily complex expressions, all checked by the compiler. There are absolutely no implicit conversions or promotions involved. > Actually, I don't think there is really a problem here wrt Ada, even > after reading your paper. Except that you can't do this in Ada, and people want to.