comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: What's class?
Date: 1999/02/24
Date: 1999-02-24T00:00:00+00:00	[thread overview]
Message-ID: <m3k8x8fovj.fsf@mheaney.ni.net> (raw)
In-Reply-To: 7av8du$rjj$1@news.kornet.nm.kr

Rouault <rouault@yahoo.com> writes:

>  What's class in Ada95?
>  
>  I should be intersted in hearing
>  more about Class.


A "class" in Ada denotes a family of types.

For tagged types, the type T'Class denotes the type T and all its
descendents.

So if I have this hierarchy:

  type T is tagged private;

     type U is new T with private;

         type W is new U with private;

     type V is new T with private;


An object of "class-wide" type T'Class can be any of the "specific" types T,
U, V, or W.

An object of class-wide type U'Class can be any of the specific types U
or W.

This distinction is nice, because it allows you to see explicitly when
you have a specific type (T), or a type and any of its descents
(T'Class).  It makes it obvious that procedures like:

  procedure Print (Stack : in Stack_Type'Class);

are intended to work for Stack_Type and any type that derives from
Stack_Type.  

Print is not a primitive operation of type Stack_Type, and therefore
doesn't get inherited during derivations from Stack_Type.  There is one
and only one Print operation, and it works for any kind of stack (that
is, those that derive from stack, i.e. in Stack_Type'Class).

But if I see this:

  function Is_Full (Stack : in Bounded_Stack) return Boolean;

then I know that Is_Full is only intended to take an object of
(specific) type Bounded_Stack.  A stack that derives from Bounded_Stack
would indeed inherit operation Is_Full.

T'Class is a "class-wide" type, which denotes a family of "specific"
types: type T, and any type that derives from T.








  parent reply	other threads:[~1999-02-24  0:00 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1999-02-23  0:00 What's class? Rouault
1999-02-23  0:00 ` David Botton
1999-02-24  0:00 ` Matthew Heaney [this message]
1999-02-23  0:00   ` bill
1999-02-24  0:00     ` Jean-Pierre Rosen
1999-02-24  0:00     ` Ed Falis
1999-02-25  0:00       ` dennison
1999-02-25  0:00     ` Matthew Heaney
1999-02-25  0:00 ` Gyeongmoon Ryu
1999-02-24  0:00   ` Matthew Heaney
replies disabled

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