comp.lang.ada
 help / color / mirror / Atom feed
From: "Yannick Duchêne Hibou57" <yannick_duchene@yahoo.fr>
Subject: Re: Discriminant and type extensions
Date: Tue, 6 Oct 2009 23:20:15 -0700 (PDT)
Date: 2009-10-06T23:20:15-07:00	[thread overview]
Message-ID: <7ca423de-7ccf-492a-acc1-875b6da695aa@z34g2000vbl.googlegroups.com> (raw)
In-Reply-To: 0d9da8c4-ab17-42b0-99ea-09ecf02435e5@x6g2000prc.googlegroups.com

On 6 oct, 01:08, Adam Beneschan <a...@irvine.com> wrote:
> then take the (Discriminant => Discriminant) off the *private*
> extension declaration.  I.e.:
>
>   type Extension_Type (Discriminant : Natural) is
>      new P1.T_Type
>      with private;
>
> But leave it on the full declaration:
>
>   type Extension_Type (Discriminant : Natural) is
>      new P1.T_Type (Discriminant => Discriminant)
>      with null record;
>
> See if that works.

Yes, it works

The message was indeed about statically matching constraint


Just beside, not directly related to this topic, but related to making
things explicit, I've found an nice way to recall about abstract
methods to be implemented by derived type.

If a base type is defined in a package and it is derived in a second
package, if it leaves some abstract methods undefined (still to be
given a concrete implementation), it can be show using both the
Overriding and Abstract clauses on the same declaration.

Here is an working example :


package P1 is

   type Base_Type is
      abstract
      tagged
      private;

   procedure Abstract_Method
     (Entity : Base_Type) is
      abstract;

private

   type Base_Type is
      abstract
      tagged
      null record;

end P1;

with P1;

package P2 is

   type Derived_Type is
      abstract
      new P1.Base_Type
      with private;

   overriding procedure Abstract_Method
     (Entity : Derived_Type) is
      abstract;
   -- Recalls about the inherited abstract method.
   -- Using both “ overriding ” and “ abstract ” is
   -- handled as expected : it does not create an
   -- homonymous method and really makes reference
   -- to the inherited one, thanks to the “ overriding ”,
   -- and clearly states it has no concrete implementation
   -- thanks to the “ abstract ”.

private

   type Derived_Type is
      abstract
      new P1.Base_Type
      with null record;

end P2;



  reply	other threads:[~2009-10-07  6:20 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-10-05 17:18 Discriminant and type extensions Hibou57 (Yannick Duchêne)
2009-10-05 20:42 ` Robert A Duff
2009-10-05 22:04   ` Adam Beneschan
2009-10-05 22:29     ` Yannick Duchêne Hibou57
2009-10-05 22:34       ` Yannick Duchêne Hibou57
2009-10-05 23:08         ` Adam Beneschan
2009-10-07  6:20           ` Yannick Duchêne Hibou57 [this message]
2009-10-05 22:15   ` Yannick Duchêne Hibou57
2009-10-09  6:29     ` Yannick Duchêne Hibou57
2009-10-09 15:42       ` Jean-Pierre Rosen
2009-10-07  7:21 ` Jean-Pierre Rosen
2009-10-07 15:39   ` Yannick Duchêne Hibou57
replies disabled

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