comp.lang.ada
 help / color / mirror / Atom feed
From: Robert A Duff <bobduff@shell01.TheWorld.com>
Subject: Re: Package's private parts and protected types
Date: Thu, 11 Feb 2010 19:05:00 -0500
Date: 2010-02-11T19:05:00-05:00	[thread overview]
Message-ID: <wccmxzfgvyr.fsf@shell01.TheWorld.com> (raw)
In-Reply-To: ca78ade5-8ed2-44ec-90e0-d2df7861c796@e19g2000prn.googlegroups.com

Adam Beneschan <adam@irvine.com> writes:

> On Feb 9, 6:56�am, Robert A Duff <bobd...@shell01.TheWorld.com> wrote:
>> AdaMagica <christoph.gr...@eurocopter.com> 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



  parent reply	other threads:[~2010-02-12  0:05 UTC|newest]

Thread overview: 51+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-02-08  4:30 Package's private parts and protected types Hibou57 (Yannick Duchêne)
2010-02-08  8:30 ` Martin
2010-02-08  9:11   ` Hibou57 (Yannick Duchêne)
2010-02-08 10:10     ` Alex R. Mosteo
2010-02-08 10:46       ` Hibou57 (Yannick Duchêne)
2010-02-09 14:55         ` Alex R. Mosteo
2010-02-08 10:20   ` Dmitry A. Kazakov
2010-02-08 10:54     ` Hibou57 (Yannick Duchêne)
2010-02-08 10:58       ` Hibou57 (Yannick Duchêne)
2010-02-08 11:01       ` Dmitry A. Kazakov
2010-02-08 13:19         ` Georg Bauhaus
2010-02-08 15:17         ` Robert A Duff
2010-02-08 16:15           ` (see below)
2010-02-08 20:44             ` Robert A Duff
2010-02-08 22:00               ` Hibou57 (Yannick Duchêne)
2010-02-09  5:48               ` AdaMagica
2010-02-09 14:56                 ` Robert A Duff
2010-02-10  2:29                   ` Randy Brukardt
2010-02-11 23:46                     ` Robert A Duff
2010-02-12  1:29                       ` Randy Brukardt
2010-02-11 23:53                     ` Robert A Duff
2010-02-12  1:10                       ` Randy Brukardt
2010-02-10 16:05                   ` Adam Beneschan
2010-02-10 20:17                     ` sjw
2010-02-12  0:05                     ` Robert A Duff [this message]
2010-02-12 11:07                       ` Stephen Leake
2010-02-12 15:01                         ` Robert A Duff
2010-02-13  8:00                           ` Stephen Leake
2010-02-09  9:04               ` stefan-lucks
2010-02-08 17:11           ` Jeffrey R. Carter
2010-02-08 14:56       ` Robert A Duff
2010-02-08 15:36         ` Dmitry A. Kazakov
2010-02-08 16:06           ` Robert A Duff
2010-02-08 17:46             ` Jean-Pierre Rosen
2010-02-08 20:39               ` Robert A Duff
2010-02-08 21:54                 ` Hibou57 (Yannick Duchêne)
2010-02-08 21:50               ` Hibou57 (Yannick Duchêne)
2010-02-08 22:04         ` Hibou57 (Yannick Duchêne)
2010-02-09 10:58         ` Hibou57 (Yannick Duchêne)
2010-02-09 14:47           ` Robert A Duff
2010-02-09 19:34             ` Hibou57 (Yannick Duchêne)
2010-02-09 20:19               ` Hibou57 (Yannick Duchêne)
2010-02-09 23:29               ` Robert A Duff
2010-02-10  2:39               ` Randy Brukardt
2010-02-10  5:12                 ` Hibou57 (Yannick Duchêne)
2010-02-10  7:17                   ` Hibou57 (Yannick Duchêne)
2010-02-10 16:09                   ` Robert A Duff
2010-02-10 22:21                     ` Hibou57 (Yannick Duchêne)
2010-02-11  0:48                       ` Robert A Duff
2010-02-09  0:48     ` Randy Brukardt
2010-02-09 12:43     ` Hibou57 (Yannick Duchêne)
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox