comp.lang.ada
 help / color / mirror / Atom feed
From: bobduff@dsd.camb.inmet.com (Bob Duff)
Subject: Re: intermediate results causing constraint errors
Date: Mon, 5 Dec 1994 18:41:31 GMT
Date: 1994-12-05T18:41:31+00:00	[thread overview]
Message-ID: <D0Cp98.1AK@inmet.camb.inmet.com> (raw)
In-Reply-To: 3bn3l9$pa2@gnat.cs.nyu.edu

In article <3bn3l9$pa2@gnat.cs.nyu.edu>, Robert Dewar <dewar@cs.nyu.edu> wrote:
>Richard Riehl worries about "constraint errors in intermediate results
>in expressions of mixed type"
>
>What's *that* about?
>
>Ada gives you complete control over the type of all intermediate results,

Robert,

I didn't see Richard Riehl's comment, but I don't understand your point.
If I write:

    type T is range 1..10_000;
    X: T := 10_000;
    Five: T := 5;
    Ten: T := 10;
    ...
    X := (X * Five) / Ten;

one implementation might overflow on the multiply and another might not.

It's true that there are ways to avoid this (define a wider-ranged type
first, and define T as a subtype of that), but I would say that that
requires some "Ada experience".  Furthermore, the Ada compiler won't
necessarily tell you about the problem, either at compiler or run-time
-- you'll find out when you try to port the code from a 32-bit machine
to a 16-bit machine (a rarity these days, I suppose).

>and you only get constraint error if you choose the wrong type. It would
>be wrong for *any* language not to give this kind of control. I simply
>don't see *any* problem here, and certainly I don't see a problem that
>needs the expertise of "experienced Ada" programmers to deal with it.

- Bob
-- 
Bob Duff                                bobduff@inmet.com
Oak Tree Software, Inc.
Ada 9X Mapping/Revision Team (Intermetrics, Inc.)



       reply	other threads:[~1994-12-05 18:41 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <3bn3l9$pa2@gnat.cs.nyu.edu>
1994-12-05 18:41 ` Bob Duff [this message]
1994-12-05 19:20   ` intermediate results causing constraint errors Bob Duff
1994-12-06  0:50   ` Keith Thompson
1994-12-06  8:00   ` Richard Riehle
1994-12-06 13:40   ` Robert Dewar
1994-12-07 17:17     ` Richard Riehle
1994-12-10 13:41       ` Robert Dewar
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox