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: a07f3367d7,cb04cee6116c8ced X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news2.google.com!newsfeed2.dallas1.level3.net!news.level3.com!bloom-beacon.mit.edu!newsswitch.lcs.mit.edu!nntp.TheWorld.com!not-for-mail From: Robert A Duff Newsgroups: comp.lang.ada Subject: Re: Package's private parts and protected types Date: Fri, 12 Feb 2010 10:01:37 -0500 Organization: The World Public Access UNIX, Brookline, MA Message-ID: References: <7ff3810f-3ee3-4f39-a54c-933ad7d0655c@36g2000yqu.googlegroups.com> <1v2la97s2yyvd.1rcy0ana8mver.dlg@40tude.net> <3bb38996-47f7-4f30-8255-f011501404b5@b10g2000yqa.googlegroups.com> <1qttzk1jbh24i$.xid2h7me3oec.dlg@40tude.net> NNTP-Posting-Host: shell01.theworld.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: pcls4.std.com 1265986887 13747 192.74.137.71 (12 Feb 2010 15:01:27 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 12 Feb 2010 15:01:27 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:iidtnnpUXs8tMjnVur1M2TkcpXg= Xref: g2news1.google.com comp.lang.ada:9168 Date: 2010-02-12T10:01:37-05:00 List-Id: Stephen Leake writes: > Robert A Duff writes: > >> Adam Beneschan writes: >> >>>...And that >>> issue exists with GNAT also---you delete some files from your >>> directory with a wildcard, somehow foo.adb accidentally gets deleted >>> along with them, and the compiler still thinks your program is OK. >> >> Seems unlikely. > > Which means it will be very hard/confusing to debug when it does > happen, since you will not be familiar with the problem. So it is > important for the tool to handle the unlikely situations nicely. I suppose... >> Here's a similar issue: One reasonable design pattern is to have >> a body that contains a type extension, which registers itself >> into some global data structure. All calls to this thing >> are indirect (via the parent's 'Class). Nobody needs visibility >> on this thing, so its spec is completely empty, except for >> the obligatory pragma Elaborate_Body. Unfortunately, if you >> forget to 'with' it, it will be silently ignored. > > And if you do 'with' it, GNAT will complain that it's unnecessary, so > you have to put a pragma Warnings (off) on it. QtAda does this for > some stuff; it's annoying. But that's a hugely useful warning. Without it, you end up with useless 'with's accumulating in your code. An occassional pragma Warnings is well worth the trouble, IMHO. > I prefer to handle that case by making the registration function > visible in the package spec, rather than calling it in the package > body execution part. Then the main program has to call it, and no > compiler warnings are generated. Self-initializing packages are a Good Thing, I think. I often do it like this: The parent type is limited controlled, and Initialize/Finalize install/remove the object into some data structure. The derived type just overrides some primitive ops (not Initialize/Finalize), and declares one or more objects -- all in some package body. - Bob