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,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,c2f62556e56c9683 X-Google-Attributes: gid103376,public From: Stuart Palin Subject: Re: 'with'ing and 'use'ing Date: 2000/03/07 Message-ID: <38C52D30.E1C7E85A@gecm.com>#1/1 X-Deja-AN: 594309539 Content-Transfer-Encoding: 7bit References: <38BC2EB3.2639372B@acm.org> <89l6aj$s5e$1@wanadoo.fr> <1e6xw1b.crkgd5nhvbzuN%claveman@inetworld.net> <8a0hio$qos$1@nnrp1.deja.com> <1e73gx5.tnnxg5v1q24gN%claveman@inetworld.net> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Trace: 7 Mar 2000 16:24:18 GMT, rc2966.rochstr.gmav.gecm.com Organization: Avionic Systems, Marconi Electronic Systems MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-03-07T00:00:00+00:00 List-Id: "Charles H. Sampson" wrote: > Not really. Here are his [M. Rosen] conclusions, quoted directly > from the paper [arguing in favour of the use clause]: > 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