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,b8b8a54001adc4d2 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!newsfeed2.dallas1.level3.net!news.level3.com!newsfeed-00.mathworks.com!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Possible Ada deficiency? Date: 08 Jan 2005 13:15:58 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <1104516913.718856.94090@z14g2000cwz.googlegroups.com> <1104544963.930877.75170@c13g2000cwb.googlegroups.com> <1104595073.731663.180100@c13g2000cwb.googlegroups.com> NNTP-Posting-Host: shell01-e.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1105208158 24436 69.38.147.31 (8 Jan 2005 18:15:58 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Sat, 8 Jan 2005 18:15:58 +0000 (UTC) User-Agent: Gnus/5.09 (Gnus v5.9.0) Emacs/21.2 Xref: g2news1.google.com comp.lang.ada:7570 Date: 2005-01-08T13:15:58-05:00 List-Id: Nick Roberts writes: > I've heard the same, and I think it might be correct. There's no real > technical barrier to types being completed in the body, other than it might > cause some compilers to have to (effectly) make an extra pass. (Correct?) I'm not sure what you mean by "extra pass". The issue is whether the compiler looks at the body while compiling clients. The main thing is that the compiler needs to know the size of a private type in order to allocate things, unless it treats all private types as dynamic-sized, which would be annoying -- you shouldn't have to pay an efficiency cost to get the benefits of encapsulation, information hiding, etc. So if the full type were in the body, the compiler would have to look at the body (at least in optimizing mode). And if the compiler looks at the body, then you have to recompile all the clients when the body changes (unless you're doing fancy incremental compilation -- that's the kind of compiler I'd really like to have!). Another point is that the rules about whether to pass by copy or by reference depend on the full type. I don't much like that, but anyway, the compiler would have to look at the body to find out, unless the decision is made at run time, which would be grossly inefficient. So I guess the Ada 83 designers invented the private part so the compiler wouldn't have to look at the body to generate efficient code. But the compiler has to look at the body anyway, in order to implement generics (unless they are always code-shared) and pragmas Inline. So the decision seems somewhat inconsistent to me. If JDI had not invented private parts, so we just had spec and body, and all the hidden stuff goes in the body, then when Tucker came along and invented child packages, he would have given them visibility into the body. And we'd be having this same discussion about how do you prevent evil children from seeing what they shouldn't. I still think the right answer is to restrict which children are allowed, rather than to have yet another special visibility rule. By the way, is the original poster worried that subunits can see all kinds of hidden stuff in the parent body? That case seems less worrisome, because the parent mentions the names of all subunits. The language could allow the same thing for children (but it shouldn't *require* it). - Bob