comp.lang.ada
 help / color / mirror / Atom feed
* Class-wide types algebra
@ 2016-09-12 20:26 Dmitry A. Kazakov
  2016-09-12 21:12 ` rieachus
  0 siblings, 1 reply; 14+ messages in thread
From: Dmitry A. Kazakov @ 2016-09-12 20:26 UTC (permalink / raw)


Presently class-wide types are singletons. I would propose to extend 
that to call-wide expressions, namely conjunction in all places where 
T'Class is expected. e.g.

    procedure Foo (X : in out T'Class and R'Class); -- Not Ada

    task type Worker (X : not null access T'Class and R'Class) is

    if X is in (T'Class and R'Class) then

    Object : T'Class and R'Class renames (T'Class and R'Class) (X);

It should not be difficult, at first glance.

Rationale. Presently it is impossible to declare an operation requiring 
an instance derived from the type T that also implements interface R. We 
cannot do that without having a explicit root type

    type T_And_R is new T and R with ...;

But that will exclude existing types already implementing T. If we 
already have:

    type S is new T with ...;

A type derived from S with R added would not fall into T_And_R.

Generics do not help much because descendants of T may have 
discriminants which are all unknown in advance, so there is no chance to 
create instances derived types.

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

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

end of thread, other threads:[~2016-10-05 20:42 UTC | newest]

Thread overview: 14+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-09-12 20:26 Class-wide types algebra Dmitry A. Kazakov
2016-09-12 21:12 ` rieachus
2016-09-12 21:39   ` Dmitry A. Kazakov
2016-09-13 11:46     ` rieachus
2016-09-13 12:26       ` Dmitry A. Kazakov
2016-09-28  0:05         ` Randy Brukardt
2016-09-28  7:31           ` Dmitry A. Kazakov
2016-09-28 20:17             ` Randy Brukardt
2016-09-29  8:06               ` Dmitry A. Kazakov
2016-09-29 18:44                 ` Randy Brukardt
2016-09-29 19:55                   ` Dmitry A. Kazakov
2016-10-01  5:47                     ` Randy Brukardt
2016-10-01  8:35                       ` Dmitry A. Kazakov
2016-10-05 20:42                         ` Randy Brukardt

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