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 Path: g2news1.google.com!news2.google.com!npeer02.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!nx01.iad01.newshosting.com!newshosting.com!198.186.194.250.MISMATCH!news-out.readnews.com!news-xxxfer.readnews.com!panix!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: Thu, 11 Feb 2010 19:05:00 -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=iso-8859-1 Content-Transfer-Encoding: 8bit X-Trace: pcls4.std.com 1265933097 16832 192.74.137.71 (12 Feb 2010 00:04:57 GMT) X-Complaints-To: abuse@TheWorld.com NNTP-Posting-Date: Fri, 12 Feb 2010 00:04:57 +0000 (UTC) User-Agent: Gnus/5.1008 (Gnus v5.10.8) Emacs/21.3 (irix) Cancel-Lock: sha1:nVCwuwge7X4X8wGA5f26Ezn0nS4= Xref: g2news1.google.com comp.lang.ada:9132 Date: 2010-02-11T19:05:00-05:00 List-Id: Adam Beneschan writes: > On Feb 9, 6:56�am, Robert A Duff wrote: >> AdaMagica writes: >> > OK, but then you have a similar problem to Ada83's syntactically >> > unneeded bodies which Ada95 solved with a pragma. >> >> I think that problem is an illusion. �There was a problem, >> but it was a problem with implementations, not with the >> language. �How do we know if a given package spec has >> a body? �Simple: look on the disk and see if there's >> a source file containing that body. �In GNAT, that would >> mean looking for foo.adb. > > And for other implementations (that put fewer restrictions on the > names and locations of source files containing the Ada source), that > would mean searching every file on the disk to see if one of them had > "package body foo" in it. :) :) Sure. I don't see a problem with that. (It's not really "every file on the disk" of course -- it's "every file with so-and-so extension in the directories where the compiler was told to look".) AdaMagic, for example, does this. The trick to making it efficient is to cache the information in a UNIT.MAP file. > I know---those other implementations wouldn't do things this way; > they'd provide some other mechanism to allow a programmer to tell the > compilation system that a package no longer requires a body---or does > require a body. But you should be careful when you say things like > "Simple...". Unless, of course, you were joking. Not joking. >...Anyway, the problem > was certainly solvable in any implementation, although as Randy points > out it's still not ideal because it makes it too easy for an > accidental error to result in the compiler accepting a package without > a body that's supposed to have one, or vice versa, causing incorrect > results at runtime that could be puzzling to track down. I suppose so, but I think that problem could be solved by a good build system, too. It could complain about stray bodies lying around the place with (misspelled) names that don't match any spec. >...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. 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. - Bob