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 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,3ef3e78eacf6f938 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!postnews.google.com!k1g2000yqf.googlegroups.com!not-for-mail From: Ludovic Brenta Newsgroups: comp.lang.eiffel,comp.lang.ada Subject: Re: Alternatives to C: ObjectPascal, Eiffel, Ada or Modula-3? Date: Mon, 20 Jul 2009 15:22:08 -0700 (PDT) Organization: http://groups.google.com Message-ID: References: NNTP-Posting-Host: 88.170.86.208 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: posting.google.com 1248128528 21296 127.0.0.1 (20 Jul 2009 22:22:08 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Mon, 20 Jul 2009 22:22:08 +0000 (UTC) Complaints-To: groups-abuse@google.com Injection-Info: k1g2000yqf.googlegroups.com; posting-host=88.170.86.208; posting-account=pcLQNgkAAAD9TrXkhkIgiY6-MDtJjIlC User-Agent: G2/1.0 X-HTTP-UserAgent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.0.11) Gecko/2009061208 Iceweasel/3.0.9 (Debian-3.0.9-1),gzip(gfe),gzip(gfe) Xref: g2news2.google.com comp.lang.eiffel:343 comp.lang.ada:7194 Date: 2009-07-20T15:22:08-07:00 List-Id: Cesar Rabak wrote on comp.lang.eiffel, comp.lang.ada: > Nicholas Paul Collin Gloucester escreveu: [...] >> In this case there is a reason for having more types. An angle and a >> length are simply not interchangable, so they should not be >> represented both by Float. The amount of money equal to U.S.$1.00 is >> not equal to the amount of money equal to 1.00 Canadian dollar, but >> they are both written with the number 1.00. > > I disagree strongly: an angle in radians is a real number as any other > there is not any intrinsic difference in its *type* on ordinary > Mathematics. Dimensionally they are 'pure numbers' with no unit > atached, your example on monetary units being fallacious, so non > sequitur. Ada is not a language for mathematicians (mathematicians would rather use e.g. Octave), it is a language for engineers. In engineering, there are very few pure numbers and quite a lot of dimensioned numbers. As an engineer, I certainly view angles, frequencies and dimensionless constants (e.g. correction factors) as all having different dimensions. I would have declared the types for angles thus: type Radians is new Float; -- no range restriction You focused too much, IMHO, on the range restriction which is not the important part. The important part is that, in Ada, this declares a new *type* (not a "subtype" or "nickname for Float"), which is *incompatible* with Float or any other type. This incompatibility has two benefits: early detection of some errors (except, of course, those involving literals of type universal_real) and documentation, to the human reader, of what objects of the type represent in the real world. [...] > > Nothing is foolproof, but I did prevent some accidents. > > Yes, I agree on that and Ada has been a step forward on this direction, > but as has been written elsewhere in this thread, Ada types do not form > a 'type system' so it brings moderate safety against errors. In Ada, floating-point literals (which were the crux of your argument) belong to the type universal_real which allows implicit conversion to any floating-point type. If I understand your argument correctly, you are suggesting that universal_real (and universal_integer) should disappear and that the language should force the programmer to qualify every literal, i.e.: X : Radians := Radians'(3.0); ? -- Ludovic Brenta.