comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: User-defined type attributes
Date: Sat, 15 Mar 2008 10:33:38 +0100
Date: 2008-03-15T10:33:38+01:00	[thread overview]
Message-ID: <13vp773bcnkwf.7zfswly78jlo$.dlg@40tude.net> (raw)
In-Reply-To: frffdo$2jo$1@jacob-sparre.dk

On Fri, 14 Mar 2008 22:04:53 -0500, Randy Brukardt wrote:

> Not if you need other generic parameters along with the type. And this is a
> way to do mixins, which otherwise can't be done in Ada 95 because type can't
> derive from a class-wide type:
> 
>    generic
>       type S is new T with private;
>    package Foo is
>       type New_S is new S with private;
>       procedure New_Operation (Op : in out New_S);
>    end Foo;
> 
> It's a nice way to add persistence, for instance. (Interfaces only allow you
> to add, umm, interfaces, not code.)

Speaking of language enhancements proper multiple inheritance would be a
better way to do this.

But actually I would like to have "supertypes" in order to be able to add
interfaces and code to existing types:

   type T is ...;  -- Defined independently on Persistent

   type Persistent is abstract...; -- Oops, we forgot to do it before T

   type Bridge is new Persistent and old T; --- (:-))

Bridge is a subtype of Persistent and a supertype of T. This injects
Bridge's implementation of Persistent into T within Bridge's scope.

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



  reply	other threads:[~2008-03-15  9:33 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-03-12 18:58 User-defined type attributes Eric Hughes
2008-03-12 21:23 ` Dmitry A. Kazakov
2008-03-13 18:32   ` Eric Hughes
2008-03-13 19:58     ` Dmitry A. Kazakov
2008-03-14  1:46       ` Randy Brukardt
2008-03-14  1:46       ` Randy Brukardt
2008-03-14  9:00         ` Dmitry A. Kazakov
2008-03-14 14:36           ` User-defined type attributes (replacing genericity) Georg Bauhaus
2008-03-15  3:04           ` User-defined type attributes Randy Brukardt
2008-03-15  9:33             ` Dmitry A. Kazakov [this message]
2008-03-14 14:31         ` User-defined type attributes (replacing genericity) Georg Bauhaus
2008-03-14 14:48           ` Dmitry A. Kazakov
2008-03-14 17:51             ` Eric Hughes
2008-03-14 18:58               ` Dmitry A. Kazakov
2008-03-14 20:19                 ` Eric Hughes
2008-03-15  4:01               ` Randy Brukardt
2008-03-14 16:58           ` Georg Bauhaus
2008-03-14 18:39             ` Dmitry A. Kazakov
2008-03-15  9:39               ` Dmitry A. Kazakov
2008-03-14  1:46       ` User-defined type attributes Randy Brukardt
2008-03-14  3:55       ` Eric Hughes
2008-03-14  9:01         ` Dmitry A. Kazakov
2008-03-14 18:04           ` Eric Hughes
2008-03-14  1:46 ` Randy Brukardt
2008-03-14  4:41   ` Eric Hughes
2008-03-15  3:20     ` Randy Brukardt
2008-03-17  4:38       ` Eric Hughes
2008-03-17 21:03         ` Randy Brukardt
2008-03-17 21:58           ` Eric Hughes
replies disabled

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