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=-0.3 required=5.0 tests=BAYES_00,FREEMAIL_FROM, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,7e60c1d99ae3ffa1 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-09-12 07:06:53 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!bloom-beacon.mit.edu!nycmny1-snh1.gtei.net!crtntx1-snh1.gtei.net!cambridge1-snf1.gtei.net!news.gtei.net!bos-service1.ext.raytheon.com!dfw-service2.ext.raytheon.com.POSTED!not-for-mail Message-ID: <3D809F51.299A6634@despammed.com> From: Wes Groleau Reply-To: wesgroleau@despammed.com X-Mailer: Mozilla 4.77 [en] (Windows NT 5.0; U) X-Accept-Language: en,es-MX,es,pt,fr-CA,fr MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Announce: The Ultimate SI Units Cracker References: Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit Date: Thu, 12 Sep 2002 09:06:09 -0500 NNTP-Posting-Host: 151.168.144.162 X-Complaints-To: news@ext.ray.com X-Trace: dfw-service2.ext.raytheon.com 1031839613 151.168.144.162 (Thu, 12 Sep 2002 09:06:53 CDT) NNTP-Posting-Date: Thu, 12 Sep 2002 09:06:53 CDT Organization: Raytheon Company Xref: archiver1.google.com comp.lang.ada:28861 Date: 2002-09-12T09:06:09-05:00 List-Id: > Yes - it's run-time consuming since the dimension is an attribute Since Ada has a 'special' meaning for attribute, perhaps 'component' or 'discriminant' would be better. Anyway, looks nice. I once implemented a package with the 'derived types' approach, and I agree that creating all the operations is a pain. I had a generic for each operator, but it was Ada 83, so the instantiations had to be in the spec, making the spec over 4,000 lines long. Someone with a little authority thought a 4,000 line spec was unacceptable, so he rewrote it non-generic, reducing the spec down to "only" 3,000 lines (and increasing the body from less than 50 to over 5,000). I like the discriminant approach, but it does have another disadvantage in that a lot of numeric operations are lost. You can't query 'First, 'Last, 'Small, etc. But maybe when dealing with physical units those don't really matter much. And of course the package can provide substitutes. You also can't provide such a type as a generic formal where a float or fixed is expected. (Speaking of which, perhaps a fixed-point version of SI would be useful to someone.) Ada 95 extended the concept of attributes being functions to letting them be procedures ('Write / 'Read), and allowed programmers to redefine/override 'Write and 'Read. I am curious whether overriding/creating other attributes was considered. Obviously, like operator overloading, it could easily be used to obfuscate, but it could be very useful to be able to define 'first and such for things like SI and Rational. It would also be nice to be able to define a type conversion. function Float (T : SI) return Float is .... What I'm getting at is the ability to define a private type so that it has all the attributes and operations of a numeric type and can be use as a generic parameter to a numeric package. I understand that many packages take advantage of the implementation of a float for efficiency, but there could be an implementation permission that allows the compiler to reject an instantiation where this is the case--or issue a warning. -- Wes Groleau http://freepages.rootsweb.com/~wgroleau