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.8 required=5.0 tests=BAYES_00,INVALID_DATE autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 109fba,ef0074ec236ba6e3 X-Google-Attributes: gid109fba,public X-Google-Thread: 108717,ef0074ec236ba6e3 X-Google-Attributes: gid108717,public X-Google-Thread: 1014db,ef0074ec236ba6e3 X-Google-Attributes: gid1014db,public X-Google-Thread: 1108a1,ef0074ec236ba6e3 X-Google-Attributes: gid1108a1,public X-Google-Thread: 103376,b19fa62fdce575f9 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 1994-11-30 15:28:39 PST Path: bga.com!news.sprintlink.net!howland.reston.ans.net!gatech!swrinde!pipex!uunet!gwu.edu!gwu.edu!not-for-mail From: mfeldman@seas.gwu.edu (Michael Feldman) Newsgroups: comp.lang.ada,comp.lang.c,comp.programming,comp.lang.c++,comp.object Subject: Re: Why don't large companies use Ada? Date: 30 Nov 1994 18:01:05 -0500 Organization: George Washington University Message-ID: <3bj07h$qus@felix.seas.gwu.edu> References: <3aa7jo$7j@Starbase.NeoSoft.COM> <3bd06n$kbt@felix.seas.gwu.edu> NNTP-Posting-Host: 128.164.9.3 Xref: bga.com comp.lang.ada:8115 comp.lang.c:32662 comp.programming:5511 comp.lang.c++:39028 comp.object:9199 Date: 1994-11-30T18:01:05-05:00 List-Id: In article , ron house wrote: >mfeldman@seas.gwu.edu (Michael Feldman) writes: > >>And not only that, it'll run on a PC. And not only that, GNAT is _free_. > >>How about "Ada - use it when your software really has to WORK." > >How about "Ada - use it when you want to multiply a length by a length >and get a length, or when you want to be prevented from dividing an area >by a length because they have different types." This is NOT my favorite aspect of the Ada type system, and I seriously wish the language directly supported dimensions. As it is, I try to avoid using derived numeric types, preferring to stick to subtypes (subrange types) which give me the necessary range checking but don't get in the way otherwise. >(PS: yes, you can fix that by defining zillions of additional *,/,- and + >functions, but good grief...) Well, there are also other solutions. One such is to use a variant record with 3 tags for the physical dimensions. This makes up into a very simple package and is bulletproof in the sense that mangled dimension-analysis will get caught either at compile time or (at worst) at run time with a nicely raised exception. My CS2-level students use and modify this package in their class projects. It does require a bit of runtime overhead, i.e. space for the tags and a bit of runtime checking, and I agree that it would be preferable to do this at compile time. But variant records are done so type-safely in Ada that this very simple solution works well. (My guess is that the runtime overhead is no more than is normally tolerated by folks who like dynamic dispatching.) I'll send the code by e-mail to anyone who wants it. Mike Feldman ------------------------------------------------------------------------ Michael B. Feldman - chair, SIGAda Education Working Group Professor, Dept. of Electrical Engineering and Computer Science The George Washington University - Washington, DC 20052 USA 202-994-5919 (voice) - 202-994-0227 (fax) - mfeldman@seas.gwu.edu (Internet) ------------------------------------------------------------------------ Ada on the World-Wide Web: http://lglwww.epfl.ch/Ada/ ------------------------------------------------------------------------ "Illegitimi non carborundum." (Don't let the bastards grind you down.) ------------------------------------------------------------------------