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.3 required=5.0 tests=BAYES_00,MAILING_LIST_MULTI, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,3885b7fd66a1db28 X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-01-11 10:34:03 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!fr.clara.net!heighliner.fr.clara.net!teaser.fr!enst.fr!not-for-mail From: "Robert C. Leif" Newsgroups: comp.lang.ada Subject: Dimension checking was RE: Why is Ada NOT a good choice for a beginner to programming? Date: Sat, 11 Jan 2003 10:32:56 -0800 Organization: ENST, France Sender: comp.lang.ada-admin@ada.eu.org Message-ID: Reply-To: comp.lang.ada@ada.eu.org NNTP-Posting-Host: marvin.enst.fr Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: quoted-printable X-Trace: avanie.enst.fr 1042310042 31979 137.194.161.2 (11 Jan 2003 18:34:02 GMT) X-Complaints-To: usenet@enst.fr NNTP-Posting-Date: Sat, 11 Jan 2003 18:34:02 +0000 (UTC) Return-Path: X-Envelope-From: rleif@rleif.com X-Envelope-To: X-Priority: 3 (Normal) X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook, Build 10.0.4510 Importance: Normal In-Reply-To: X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org X-Mailman-Version: 2.0.13 Precedence: bulk List-Unsubscribe: , List-Id: comp.lang.ada mail<->news gateway List-Post: List-Help: List-Subscribe: , Errors-To: comp.lang.ada-admin@ada.eu.org X-BeenThere: comp.lang.ada@ada.eu.org Xref: archiver1.google.com comp.lang.ada:32920 Date: 2003-01-11T10:32:56-08:00 An obvious fix, which was discussed at SIGAda 2002, is to develop a = means (Pragma?) to tell the compiler to only check the dimensionality at = compile time. This could be in the form of a compile time assertion. Bob Leif -----Original Message----- From: comp.lang.ada-admin@ada.eu.org = [mailto:comp.lang.ada-admin@ada.eu.org] On Behalf Of Kevin Cline Sent: Friday, January 10, 2003 7:51 AM To: comp.lang.ada@ada.eu.org Subject: Re: Why is Ada NOT a good choice for a beginner to programming? "Grein, Christoph" wrote in message news:... > > > One complaint he had was that it be possible to define a Length > > > using derived types and still have "*" return values of type = Length, > > > when it should return an area. He had a point, hadn't he? > > > OTOH, with only structural equivalence of types, and no way to = derive > > > both an integral length type and an integral area type, that are really > > > diferent, how can you build areas into your types, such that the compiler > > > will prevent use of values of the wrong type? > > >=20 > > > In which languages has this been fixed? > >=20 > > This is relatively easy to do in C++. > > See http://www.fnal.gov/docs/working-groups/fpcltf/html/SIunits-summary.html >=20 > This is also easy in Ada. >=20 > For a collection of methods how to deal with dimensions in Ada, see > Did you read Grein's paper? He says that it was not easy at all. Grein writes: But the request to have full dimensional checking persists as can be = seen from the pertinent discussions in newsgroup Comp.Lang.Ada. There are = two basic ways one can try to solve the problem, either by adding to the numeric value its dimension as attribute, or by using different types = for different dimensions. Since the first method is runtime-consuming, whereas the second one is only compiletime-consuming, all effort = naturally concentrates on the second method. This is doomed to fail as is shown in the paper cited above - although a plethora of = overloaded operations is used, the result is not really satisfactory. Physical equations with all their powers and roots evade these = attempts. In short, Ada's requirement for explicit generic instantiation repels attempts to create a compile-time verified system of dimensional types, and Grein gave up on attempts to achieve compile-time type safety. C++ does not have this problem, and compile-time type safety is achieved in a fairly obvious way.