comp.lang.ada
 help / color / mirror / Atom feed
From: Stuart Palin <stuart.palin@gecm.com>
Subject: Re: 'with'ing and 'use'ing
Date: 2000/03/07
Date: 2000-03-07T00:00:00+00:00	[thread overview]
Message-ID: <38C52D30.E1C7E85A@gecm.com> (raw)
In-Reply-To: 1e73gx5.tnnxg5v1q24gN%claveman@inetworld.net

"Charles H. Sampson" wrote:

<snip>

>  Not really.  Here are his [M. Rosen] conclusions, quoted directly
>  from the paper [arguing in favour of the use clause]:

<snip>
 
>           Of course, like any other feature, the use clause can be
>      abused of... and I don't know of any feature, even in Ada,
>      where this is not true . But apart from pathological cases,
>      reasonable use of the use clause provides more information to
>      the reader, and should be recommended as the usual practice.

It seems to me that the points raised in the c.l.a thread
"choice of fixed point type" highlight an area where the "use" clause
can give rise to some concerns.

tmoran@bix.com wrote
> The code in question arose from testing around an "Ada
> surprise".  An execution error had been traced to where a
> programmer had written something like
>   Long_Float(N * Ada.Numerics.pi)   instead of
>   Long_Float(N) * Ada.Numerics.pi
> resulting in the use of (relatively imprecise) type Duration
> for the multiply instead of Long_Float.  Standard.Duration
> was of course (silently) visible, and there was no other
> fixed point type in this code, so the compiler did what the
> programmer said, but not what he wanted.

Although an explicit "use clause" was not part of the difficulty here,
it seems that bringing things into scope unnecessarily increases the
possibility of this type of anomaly; where what is said is not what is
wanted and the compiler does not report an error because it can
interpret what was said.

This type of "gotcha" is a legitimate concern.  Even so rigorous
abstention from the use clause only limits the risk, it does not
eliminate it (since the unintended behaviour might fall within the
bounds of those things that have been brought into scope by either
renaming or "use type").

In this example the difficulties of detecting the error by testing can
be recognized - the error would only be apparent if the values chosen
gave intermediate results that were significantly different from the
model numbers (and so introduced rounding errors).

Regards
--
Stuart Palin
BAE SYSTEMS Electronics Limited




  reply	other threads:[~2000-03-07  0:00 UTC|newest]

Thread overview: 55+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2000-02-29  0:00 'with'ing and 'use'ing Roger Hoyle
2000-02-29  0:00 ` David Starner
2000-02-29  0:00 ` Robert A Duff
2000-02-29  0:00   ` Ted Dennison
2000-03-01  0:00   ` Robert Dewar
2000-02-29  0:00 ` xl
2000-02-29  0:00   ` Jeffrey Carter
2000-02-29  0:00     ` xl
2000-03-01  0:00   ` Roger Hoyle
2000-02-29  0:00 ` Ted Dennison
2000-03-01  0:00   ` Robert Dewar
2000-03-01  0:00     ` Ted Dennison
2000-03-01  0:00       ` Robert Dewar
2000-03-01  0:00         ` Ted Dennison
2000-03-01  0:00           ` Wes Groleau
2000-03-02  0:00             ` Robert Dewar
2000-02-29  0:00 ` Jeffrey Carter
2000-02-29  0:00   ` Brian Rogoff
2000-03-01  0:00     ` Jean-Pierre Rosen
2000-03-02  0:00       ` Charles Hixson
2000-03-02  0:00         ` Robert A Duff
2000-03-02  0:00           ` Ted Dennison
2000-03-02  0:00             ` Charles Hixson
2000-03-02  0:00               ` David Starner
2000-03-03  0:00                 ` Ted Dennison
2000-03-07  0:00                   ` Nick Roberts
2000-03-03  0:00                 ` Jeff Carter
2000-03-03  0:00                   ` David Starner
2000-03-04  0:00                     ` Simon Wright
2000-03-03  0:00               ` Larry Kilgallen
2000-03-03  0:00               ` Marin D. Condic
2000-03-03  0:00                 ` Scott Ingram
2000-03-04  0:00                   ` Simon Wright
2000-03-04  0:00               ` Robert Dewar
2000-03-04  0:00                 ` Ehud Lamm
2000-03-06  0:00                 ` Charles Hixson
2000-03-06  0:00                   ` Robert Dewar
2000-03-03  0:00       ` Charles H. Sampson
2000-03-04  0:00         ` Jean-Pierre Rosen
2000-03-06  0:00         ` Ted Dennison
2000-03-06  0:00           ` Robert Dewar
2000-03-07  0:00             ` Ted Dennison
2000-03-08  0:00               ` Robert Dewar
2000-03-11  0:00                 ` Robert A Duff
2000-03-06  0:00           ` Ted Dennison
2000-03-06  0:00             ` Robert A Duff
2000-03-06  0:00               ` tmoran
2000-03-06  0:00             ` Robert Dewar
2000-03-07  0:00               ` Marin D. Condic
2000-03-07  0:00               ` Ted Dennison
2000-03-07  0:00             ` Marin D. Condic
2000-03-06  0:00           ` Charles H. Sampson
2000-03-07  0:00             ` Stuart Palin [this message]
2000-03-08  0:00               ` Robert Dewar
2000-03-09  0:00                 ` Stuart Palin
replies disabled

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