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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: 103376,2a687662f09731bb X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!news2.volia.net!news.musoftware.de!news.karotte.org!uucp.gnuu.de!newsfeed.arcor.de!news.arcor.de!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: Don't use the "use" clause Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.14.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <1132227919.9036.51.camel@sonnenregen> <1132233886.11218.11.camel@sonnenregen> <1ef4kvy6kdkwz.oqmb8acj5joo.dlg@40tude.net> Date: Sun, 20 Nov 2005 12:07:04 +0100 Message-ID: <1jmopc0bqnxw6$.gad3gye7lnjg$.dlg@40tude.net> NNTP-Posting-Date: 20 Nov 2005 12:07:02 MET NNTP-Posting-Host: 35a1e6e0.newsread2.arcor-online.net X-Trace: DXC=L@T\KEmfbb]XNWN: On Sat, 19 Nov 2005 23:40:46 GMT, Anonymous Coward wrote: > In article <1ef4kvy6kdkwz.oqmb8acj5joo.dlg@40tude.net>, > Dmitry A. Kazakov wrote: >> >> No, name collisions better be prevented by making "use" illegal when >> it hides anything. > > The use clause is barred by coding standards for a good reason, and I > don't think it's necessarily name collisions that drive this rule. What else then? > Programmers are forced to resolve name collisions, with or without the > USE clause. No. Don't refer to conflicting names and the compiler won't object. This is IMO bad. > The use clause is banned because it makes code unreadable > and difficult to use. As Joel Spolsky said, travel should be minimal > when interpretting a line of code. Fully qualified naming is a better > style because you know immediately, from the code itself, where the > identifier lives. And if you need to see the declaration, you know > immediately where to go. How so? Why should I care about the declaration/definition places? What should be a fully qualified name of a dispatching call to a 10-times overridden primitive operation, provided that 5 of them were private? The first, the last, one in the middle? >> BTW, what about banning implicit "use" of "Standard"? Care to write >> an AI to make Integer, "+", "-" etc invisible? (:-)) > > The "use type" clause is a different beast, and I do not object to its > use; nor is it banned in any coding standard I've read. What is the difference between "+" and "Add"? >>> Then to possibly get multiple hits and have to compare two lists of >>> packages to discover which hit is the correct one. By the time you >>> make it to the declaration you're looking for, you've forgotten why >>> you need to look at it :) >> >> It is no matter "where", "what" does matter. If you need to >> frequently browse sources to determine "what", then the program is >> poorly designed. > > Certainly not. I would say just the opposit. If you're repeating > information from your declaration in your identifiers, then you've > created a maintenance problem by introducing too much noise, also > forcing identifiers to change whenever the declaration changes. A > good design doesn't repeat this information. It seems that you are arguing my point. Name prefix is that noise you are talking about. >>> Clearly the typing time saved by the use clause cannot possibly offset >>> the time lost on all the resulting code searches. >> >> What about the time spent on reading something like A.B.C.D.E.F.G.H? > > If you have something like that, then there's something wrong with the > architecture of your project. A user should not need visibility into > such a deep level within an external component. That might be true, but irrelevant because the implementation of H should know A and A.B and A.B.C etc. According to your theory within H anything from G must be referred as A.B.C.D.E.F.G.X! Now if you aren't going to argue against child packages, consider "use A" as an ad-hoc parent specification. BTW, one probably could even remove "use" from the language allowing multiple parents instead. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de