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/09 Message-ID: <38C795F3.9D0DCD39@gecm.com>#1/1 X-Deja-AN: 595133305 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> <38C52D30.E1C7E85A@gecm.com> <8a6fsj$6dr$1@nnrp1.deja.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Trace: 9 Mar 2000 12:15:34 GMT, rc2966.rochstr.gmav.gecm.com Organization: Avionic Systems, Marconi Electronic Systems MIME-Version: 1.0 Newsgroups: comp.lang.ada Date: 2000-03-09T00:00:00+00:00 List-Id: Robert Dewar wrote: > > In article <38C52D30.E1C7E85A@gecm.com>, > Stuart Palin wrote: > > > 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. > > Nope, you are misreading the thread. This thread was about Quite possibly! > a) ambiguities not detected that should be. Obviously adding > use clauses NEVER causes undetected ambiguities. True - because the compiler is supposed to report an error if there is an ambiguity. > b) the concern that certain expressions are compiled > misleadingly because only one fixed-point type is > visible. Use clauses can *only* help in this regard. This is more the area I was concerned with. First a caveat - I am working with Ada-83, and I do not know whether what follows works differently under Ada-95. Suppose I (rather pathologically) have: package P1 is type Gx is range -1000..1000; function I return Gx; function K return float; end P1; package P2 is type Fx is delta 0.1 range -200.0 .. 200.0; function I return Fx; function K return Fx; end P2; And then I start writing a new package: package P3 is end P3; with P1, P2; use P1,P2; package body P3 is X : float; begin -- Now I "intend" to do : X := float(P1.I) * P1.K; -- But foolishly write: X := float(I * K); -- This will be compiled (under Ada-83) as : X := float(P2.I * P2.K); end P3; If I had written (what I probably should have written if I did not believe there was an ambiguity due to P2 being in scope) X := float(I) * K; then the compiler would have warned me about the ambiguity (at least of I). I believe it is a concern that a mistake can be hidden, because another valid (but unexpected) meaning can be "found" by the compiler, that leads people to "distrust" using "use". Regards -- Stuart Palin BAE SYSTEMS Electronics Limited