comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Extend Record in Spec and Body
Date: Tue, 17 Oct 2006 09:30:39 +0200
Date: 2006-10-17T09:30:38+02:00	[thread overview]
Message-ID: <acayl5xzj1xx.qr6vffqk731z.dlg@40tude.net> (raw)
In-Reply-To: 1161012646.433304.176150@m7g2000cwm.googlegroups.com

On 16 Oct 2006 08:30:46 -0700, richard.charts@gmail.com wrote:

> Is it possible to extend a record twice in a package?

Yes, but not in the body and each extension would produce a new type.

> I'm building a component now that will be mostly reusable.  There are a
> couple packages that are the same, but for one piece the differences
> require different code.  However, with the way it is designed, it seems
> I could make the package specs the same and only alter the bodies.
> I would like to try to hide part of the extended record from the
> specification without having to change  the operation declarations.

You cannot do it in the body and you cannot do it so that both extensions
were looked as one type. But you can make one extension public and another
private:

   type Transient_Object is abstract new HigherPackage.object with record
      <public things>
   end record;

   type Object is new Transient_Object with private;
private
   type Object is new Transient_Object with record
      <private things>
   end record;

Well, if the public things are read-only you could expose them through
getters using the prefix interface (new in Ada 2005), and then move
everything into private.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  parent reply	other threads:[~2006-10-17  7:30 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-10-16 15:30 Extend Record in Spec and Body richard.charts
2006-10-16 16:53 ` Jean-Pierre Rosen
2006-10-16 17:20   ` Richard Charts
2006-10-17  0:33     ` Georg Bauhaus
2006-10-17  1:11     ` Randy Brukardt
2006-10-17  7:30 ` Dmitry A. Kazakov [this message]
2006-10-17 18:49   ` Simon Wright
2006-10-17 20:19     ` Dmitry A. Kazakov
replies disabled

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