comp.lang.ada
 help / color / mirror / Atom feed
* hunting snarks
@ 1999-12-14  0:00 Stephen Leake
  1999-12-14  0:00 ` Robert A Duff
  0 siblings, 1 reply; 6+ messages in thread
From: Stephen Leake @ 1999-12-14  0:00 UTC (permalink / raw)


I wasted a couple of hours this past weekend due to what I propose we
call "the snark effect". The snark effect occurs when you change the
profile of a dispatching operation, and forget to change one of the
overriding operations on a derived type; the overriding operation
"silently vanishes away".

Connoisseurs of Lewis Carrol will protest that this should be the
"boojum snark effect", but that's too many words.

Anyway, this problem has been mentioned here before. I'm considering
hacking into GNAT to provide a fix, probably in the form of a pragma
Overrides. But first, I'd like to check if anyone else is working on a
solution, or has a proposal for a syntax for a solution.

Anyone?

-- Stephe




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: hunting snarks
  1999-12-14  0:00 hunting snarks Stephen Leake
@ 1999-12-14  0:00 ` Robert A Duff
  1999-12-14  0:00   ` Tucker Taft
  0 siblings, 1 reply; 6+ messages in thread
From: Robert A Duff @ 1999-12-14  0:00 UTC (permalink / raw)


Stephen Leake <Stephen.Leake@gsfc.nasa.gov> writes:

> Anyway, this problem has been mentioned here before. I'm considering
> hacking into GNAT to provide a fix, probably in the form of a pragma
> Overrides. But first, I'd like to check if anyone else is working on a
> solution, or has a proposal for a syntax for a solution.

Somebody proposed a pragma along those lines to the ARG recently.
Check out the Ada Issues.

- Bob




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: hunting snarks
  1999-12-14  0:00 ` Robert A Duff
@ 1999-12-14  0:00   ` Tucker Taft
  1999-12-17  0:00     ` Simon Wright
  0 siblings, 1 reply; 6+ messages in thread
From: Tucker Taft @ 1999-12-14  0:00 UTC (permalink / raw)


Robert A Duff wrote:
> 
> Stephen Leake <Stephen.Leake@gsfc.nasa.gov> writes:
> 
> > Anyway, this problem has been mentioned here before. I'm considering
> > hacking into GNAT to provide a fix, probably in the form of a pragma
> > Overrides. But first, I'd like to check if anyone else is working on a
> > solution, or has a proposal for a syntax for a solution.
> 
> Somebody proposed a pragma along those lines to the ARG recently.
> Check out the Ada Issues.

As mentioned in another reply, the relevant AI is:
    http://www.ada-auth.org/cgi-bin-acats/cvsweb.cgi/AIs/AI-00218.DOC?rev=1.3

The basic idea is a pragma Overrides that means a subprogram
*must* be overriding something, and a configuration pragma Explicit_Overriding
that means that any subprogram without a pragma Overrides must *not*
be overriding something.  For special cases involving generics which
declare a type derived from a formal type, there is also a pragma
Might_Override which overrules Explicit_Overriding, to indicate that the
given subprogram might or might not override..

> 
> - Bob

-- 
-Tucker Taft   stt@averstar.com   http://www.averstar.com/~stt/
Technical Director, Distributed IT Solutions  (www.averstar.com/tools)
AverStar (formerly Intermetrics, Inc.)   Burlington, MA  USA




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: hunting snarks
  1999-12-14  0:00   ` Tucker Taft
@ 1999-12-17  0:00     ` Simon Wright
  1999-12-20  0:00       ` Tucker Taft
  0 siblings, 1 reply; 6+ messages in thread
From: Simon Wright @ 1999-12-17  0:00 UTC (permalink / raw)


Tucker Taft <stt@averstar.com> writes:
[...]
>                           For special cases involving generics which
> declare a type derived from a formal type, there is also a pragma
> Might_Override which overrules Explicit_Overriding, to indicate that the
> given subprogram might or might not override..

Doesn't sound like the sort of thing to encourage the safety guys to
let us use all (any of) the good things in Ada!

Isn't accidental overriding almost bound to lead to error? (wasn't
that the point at which all this started?)




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: hunting snarks
  1999-12-17  0:00     ` Simon Wright
@ 1999-12-20  0:00       ` Tucker Taft
  1999-12-21  0:00         ` Robert I. Eachus
  0 siblings, 1 reply; 6+ messages in thread
From: Tucker Taft @ 1999-12-20  0:00 UTC (permalink / raw)


Simon Wright wrote:
> 
> Tucker Taft <stt@averstar.com> writes:
> [...]
> >                           For special cases involving generics which
> > declare a type derived from a formal type, there is also a pragma
> > Might_Override which overrules Explicit_Overriding, to indicate that the
> > given subprogram might or might not override..
> 
> Doesn't sound like the sort of thing to encourage the safety guys to
> let us use all (any of) the good things in Ada!
> 
> Isn't accidental overriding almost bound to lead to error? (wasn't
> that the point at which all this started?)

When defining a generic "mix-in" it is quite reasonable to
have an operation that overrides an inherited operation.  It is
also just as reasonable to be creating a new operation.  It really
requires knowledge of the particular instantiation in some cases,
and clearly you don't have that knowledge when writing the
generic itself.  So that is what this pragma is used for.
The pragma is not to be read as "allow accidental overriding" but rather
as "allow intentional overriding upon instantiation."

For anyone instantiating the generic, this is presumably a
flag to indicate that some additional care may be required here.
Without the pragma, you might be forced to create two versions
of the same generic, one with a pragma Overrides, and one without, 
which definitely seems like overkill in some situations.


-- 
-Tucker Taft   stt@averstar.com   http://www.averstar.com/~stt/
Technical Director, Distributed IT Solutions  (www.averstar.com/tools)
AverStar (formerly Intermetrics, Inc.)   Burlington, MA  USA




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: hunting snarks
  1999-12-20  0:00       ` Tucker Taft
@ 1999-12-21  0:00         ` Robert I. Eachus
  0 siblings, 0 replies; 6+ messages in thread
From: Robert I. Eachus @ 1999-12-21  0:00 UTC (permalink / raw)


Tucker Taft wrote:
 
> When defining a generic "mix-in" it is quite reasonable to
> have an operation that overrides an inherited operation.  It is
> also just as reasonable to be creating a new operation.  It really
> requires knowledge of the particular instantiation in some cases,
> and clearly you don't have that knowledge when writing the
> generic itself.  So that is what this pragma is used for.
> The pragma is not to be read as "allow accidental overriding" but rather
> as "allow intentional overriding upon instantiation."

  There is another idiom where you extend an (abstract) type using
several instantiation, and then export the final result as a concete
type.  When using this to extend a type by adding both operations and
state/data fields.  It can be the case that some extentions have similar
profiles, and thus override, but neither the author of the mix-in or the
user cares.  (From the user's viewpoint, the (actually overridden)
operations are overloaded, and require qualification or renaming, while
from the author's viewpoint, he cannot see and never cares about the
other inherited operations.

   Sound complex?  It isn't, and actually allows a classical abstract
type to be constructed from many components.  Due to the way
generics/templates work, you have three levels of abstraction.  The user
and the component author see a single level, and the creator of the
abstract type deals only with explicit interactions required by the
design.  There are no implicit interactions to trip him up.
  
> For anyone instantiating the generic, this is presumably a
> flag to indicate that some additional care may be required here.
> Without the pragma, you might be forced to create two versions
> of the same generic, one with a pragma Overrides, and one without,
> which definitely seems like overkill in some situations.

   And an invitation to a combinatorial explosion.
-- 

                                        Robert I. Eachus

with Standard_Disclaimer;
use  Standard_Disclaimer;
function Message (Text: in Clever_Ideas) return Better_Ideas is...




^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~1999-12-21  0:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1999-12-14  0:00 hunting snarks Stephen Leake
1999-12-14  0:00 ` Robert A Duff
1999-12-14  0:00   ` Tucker Taft
1999-12-17  0:00     ` Simon Wright
1999-12-20  0:00       ` Tucker Taft
1999-12-21  0:00         ` Robert I. Eachus

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