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-Thread: 103376,89cb2d7ffc7421c9 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news3.google.com!news4.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local02.nntp.dca.giganews.com!nntp.megapath.net!news.megapath.net.POSTED!not-for-mail NNTP-Posting-Date: Tue, 05 Sep 2006 19:08:59 -0500 From: "Randy Brukardt" Newsgroups: comp.lang.ada References: Subject: Re: Ripple effect Date: Tue, 5 Sep 2006 19:10:27 -0500 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1807 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1807 Message-ID: NNTP-Posting-Host: 64.32.209.38 X-Trace: sv3-kIlxIolcwXqrb8Ud3xCjPDtGM4jUsW/8pV+55K7cGnAuIP3UN9AwXDHuXk19WfGVX89O+qATPZG8l4v!ER0N4iPXmwDbWvN4ZMN3oCcw3joYkfXkr9f0P5VdL4DRU1HGuodfwjhtaghaaIBjDOD1wQuSpz1q!dBnFc3GYZXBDTA== X-Complaints-To: abuse@megapath.net X-DMCA-Complaints-To: abuse@megapath.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.32 Xref: g2news2.google.com comp.lang.ada:6459 Date: 2006-09-05T19:10:27-05:00 List-Id: "Robert A Duff" wrote in message news:wccpseab7u4.fsf@shell01.TheWorld.com... > "Jeffrey R. Carter" writes: > > It seems awkward. We're working on a project. I create package B, which > > has "with A;" on it. I thought B would need it, but I was wrong, and > > forgot to remove it. You're developing C and need to use B, so you have > > "with B;" on C. Then you realize you need to use A and write some code > > that references A. You forget to put "with A;" on C, but it compiles OK > > because B references A. Then I clean up B and remove the reference to A > > from it. Now C doesn't compile. That seems undesirable. > > It does not bother me that a change to the visible part of A affects > clients, transitively. That has to be true, in general. > > My thinking is that if B uses A in a visible way, C pretty-much has to > know about A. E.g.: > > with A; > package B is > procedue Mumble(X: A.T); > end B; > > If C uses B.Mumble, it most likely needs to declare objects of type A.T. > C certainly knows about type A.T! I guess I disagree -- simply knowing about a type doesn't require objects to be created. Indeed, I spent a lot of effort (and other did too, I don't want to appear to be taking all of the credit) to ensure that limited withs don't require a regular with of a unit unless that unit actually needs to create an object. (If the object comes from somewhere else -- a common case, such as when an access to it is passed in -- no with is needed). In any case, most of the problem withs are either unused completely (because of maintenance) or only exist for the private part (a good package has very few visible dependencies). > So non-transitive with's cause a lot > of clutter -- C needs to 'with' everything it uses, plus everything > those things are (visibly) based on, transitively. So high-level > packages tend to have so many with_clauses that nobody wants to read > them, largely defeating the purpose. Only if the lower level packages have a lot of dependencies, and way too many things are used in one place. The Janus/Ada compiler's code looks like you suggest (although I think it is a benefit, not a problem, because it encourages better structure), but most of our more modern programs either don't have such things at all, or have them specifically to solve elaboration issues [that's a different subject altogether]. Even for Janus/Ada, no one reads the top-level packages, because they consist of little more than "parse program", "load predefined symbols", "load symbols for context clause", "handle semantics for program, making intermediate code", "optimize intermediate code", and "generate code for intermediate code". Rarely does that need maintenance! > OTOH, if B uses A only for implementation, that's a different story. > Then the import of A belongs on the body of B, and C shouldn't know > about it. (My language doesn't have private parts.) > > By the way, the issue of bogus with_clauses is a real maintenance > problem -- nobody ever deletes a with_clause, so they tend to > accumulate. Huh? I often check for unused with clauses in my programs - by hand, and generally not because of compiler warnings (although we get those, too). I often try to eliminate things that are used only once. I guess I'd agree more if you said "rarely" as opposed to "ever". > This problem is easily solved. The compiler should give an > error message. An error that can be suppressed, so that you can > temporarily have bogus with_clauses during development. That's > essentially what GNAT does, with appropriate warning switches. Don't all Ada compilers at least have a warning? Janus/Ada always has (perhaps because of our focus on space -- loading unnecessary junk into an already tight space doesn't make sense). Unusued with clauses can be a significant performance drag on compilation, among other things. As I said, I often check with clauses, even before compiling (so I don't see the warning). Randy.