comp.lang.ada
 help / color / mirror / Atom feed
From: "Grein, Christoph" <christoph.grein@eurocopter.com>
Subject: Re: Invoking abstract subprograms in Ada95
Date: Mon, 22 Apr 2002 15:44:31 +0200 (MET DST)
Date: 2002-04-22T15:44:31+02:00	[thread overview]
Message-ID: <mailman.1019483282.562.comp.lang.ada@ada.eu.org> (raw)

> "Grein, Christoph" <christoph.grein@eurocopter.com> wrote in message 
news:<mailman.1019449992.18314.comp.lang.ada@ada.eu.org>...
> > The following compiles fine (with Rational Apex):
> > 
> > 
> > package Abstract_Class_Wide is
> > 
> >     type T is abstract tagged null record;
> > 
> >     procedure P (X : T) is abstract;
> > 
> >     procedure C (X : T'Class);
> > 
> > end Abstract_Class_Wide;
> > 
> > 
> > 
> > package body Abstract_Class_Wide is
> > 
> >     procedure C (X : T'Class) is
> >     begin
> > 	P (X);
> >     end C;
> > 
> > end Abstract_Class_Wide;
> 
> Hmm - the only differences I can see here are that my abstract method
> also takes a classwide type, and is implemented in a child package.
> Here's the distilled problem:
> 
> --
> package abstract_bit is
> 
> type A is abstract tagged null record;
> 
> procedure generalOperation( this : in out A'class );
> procedure specificOperation( this : in out A'class ) is abstract;


Class-wide operations cannot be abstract, they also cannot be overrridden.

OK, they can be abstract, this is why your code compiles, but abstractness here 
has a devastating meaning: There can never be such an operation!


> end abstract_bit;
> 
> --
> package body abstract_bit is
> 
> procedure generalOperation( this : in out A'class ) is
> begin
>     specificOperation( this => this );

You said it was abstract, so does not exist! Therefore you cannot call it here.


> end generalOperation;
> 
> end abstract_bit;
> 
> --
> package abstract_bit.concrete_bit is
> 
> type C is new A with null record;
> 
> procedure specificOperation( this : in out C );
> 
> end abstract_bit.concrete_bit;
> 
> 
> --
> package body abstract_bit.concrete_bit is
> 
> procedure specificOperation( this : in out C ) is
> begin
>     null;
> end specificOperation;
> 
> end abstract_bit.concrete_bit;
> 
> -- main program
> with abstract_bit.concrete_bit;
> 
> procedure annoying is
> 
> thingy : abstract_bit.concrete_bit.C;
> 
> begin
>     abstract_bit.generalOperation( thingy );
> end annoying;
> 
> 
> Mike
> _______________________________________________
> comp.lang.ada mailing list
> comp.lang.ada@ada.eu.org
> http://ada.eu.org/mailman/listinfo/comp.lang.ada



             reply	other threads:[~2002-04-22 13:44 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-04-22 13:44 Grein, Christoph [this message]
2002-04-23  8:36 ` Invoking abstract subprograms in Ada95 Mike
  -- strict thread matches above, loose matches on Subject: below --
2002-04-24  7:32 Grein, Christoph
2002-04-22  4:28 Grein, Christoph
2002-04-22 13:24 ` Mike
2002-04-22 14:24   ` Dmitry A. Kazakov
2002-04-19 13:15 Mike
2002-04-19 16:18 ` Stephen Leake
replies disabled

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