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-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4c459ff0adb576bc X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2002-02-07 10:31:11 PST Path: archiver1.google.com!news1.google.com!newsfeed.stanford.edu!news-spur1.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed00.sul.t-online.de!t-online.de!blackbush.xlink.net!blackbush.de.kpnqwest.net!rz.uni-karlsruhe.de!schlund.de!news.online.de!not-for-mail From: "Dr. Michael Paus" Newsgroups: comp.lang.ada Subject: Re: Refactoring and Ada Date: Thu, 07 Feb 2002 19:31:08 +0100 Organization: =?iso-8859-1?Q?Ingenieurb=FCro?= Dr. Paus Message-ID: <3C62C7EC.4ACBC1@ib-paus.com> References: NNTP-Posting-Host: p508305f9.dip0.t-ipconnect.de Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Trace: news.online.de 1013106669 391 80.131.5.249 (7 Feb 2002 18:31:09 GMT) X-Complaints-To: abuse@online.de NNTP-Posting-Date: 7 Feb 2002 18:31:09 GMT X-Mailer: Mozilla 4.75 [de]C-CCK-MCD DT (Win98; U) X-Accept-Language: de Xref: archiver1.google.com comp.lang.ada:19723 Date: 2002-02-07T18:31:09+00:00 List-Id: Christoph Grein wrote: > > > > I often find that people think that avoiding use clauses > > > avoids this, and requires full qualification. In fact in > > > the above example, suppose the only other occurrence of > > > f is in package p, then it is the case that trying to > > > qualify by writing > > > > > > a := p.f (x); > > > > > > is not just unnecessary, but in fact illegal. > > > > If I understand your example correctly, it reflects a problem > > which I recently had to fix in program written by someone else. > > We had the requirement not to use use and so the call of f had > > to be qualified as in your example above. The compiler complained > > about this of course and can you imagine what the programmer did > > in order to fix the problem? The type of x (B_Type) was derived from > > some other type (let's say A_Type). So the programmer wrote: > > > > a := p.f (p.A_Type(x)); > > > > Silliness is indeed unbounded. The person requiring qualification of > of the call of f should have been sent to purgatory immediately. > > The programmer should have declined to do this and explain the reason > why. > > > The compiler was happy and in this particular case the program > > even did what it was assumed to do. The hidden bug in this > > statement is a maintenance time-bomb which would not have occurred > > if use had been used. > > But I do not see how "use" comes into the picture here. Quite simple. When use clauses are allowed to be used, then the programmer would have used the package where the type of x is defined and then he would have just written: a := f(x); In this case the compiler would choose the right package and function compatibel with x. It was the false attempt to qualify the call of f which lead to the described problem. And the first mistake was cured by an even bigger mistake (the type cast). I personally do not like qualification of primitive operations anyway. If I access an element s of a tagged type B_Type (as in the example before) defined in a package G, I write declare x : G.B_Type; begin a := x.s; end; and nobody would feal that there is any need for more qualification and so I do not see why it should then be usefull to qualify a call to a primitive operation. If Ada had adopted the C++ or Java notation in this case the function call would be written as a := x.f; and just because you have to write a := f(x); in Ada95 does not justify a qualification. If I really want to know where this function is defined it is sufficient to look at the declaration of x so that you know where the type is defined and you have to go on and search for the place where the parent type of B_Type is defined because in case of an inherited function it is not physically located in the package that you have to use for the qualification. But of course like everything this is a matter of taste and I do not want to start another flame war on the use of use. Michael