comp.lang.ada
 help / color / mirror / Atom feed
* Deriving from non-null abstract type
@ 1995-03-29  0:00 Moti Ben-Ari
  1995-03-29  0:00 ` Tucker Taft
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Moti Ben-Ari @ 1995-03-29  0:00 UTC (permalink / raw)


I would like to derive from a _non-null_ abstract tagged type:

  type Abstract_Type is abstract tagged
    record
      General_Info: Some_Type;
    end record;

  type Derived_Type is new Abstract_Type with
    record
      Special_Info: Some_Other_Type;
    end record;

Of course, you can't create a value of the abstract type,
but it turns out that it is impossible to create a value
of the derived type:

    D: Derived_Type := (G with S);

because G would have to be an aggregate of an abstract type 
which is illegal. The only thing you can do is:

  D: Derived_Type := (Abstract_Type with S);

which means that the component General_Info has to
be initialized in a separate statement.
This seems to be against the philosophy of Ada which
provides aggregates so that you won't forget to initialize
a component.

Is there some way of creating a value that I don't see?
If not, why aren't abstract types restricted to null records?

Moti

Moti Ben-Ari
benari@datasrv.co.il






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

end of thread, other threads:[~1995-03-30  1:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1995-03-29  0:00 Deriving from non-null abstract type Moti Ben-Ari
1995-03-29  0:00 ` Tucker Taft
1995-03-29  0:00 ` Robert I. Eachus
1995-03-30  0:00   ` Tucker Taft
1995-03-30  1:53 ` Dan Johnston D.B.

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