From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,fa1a697e52242fbf X-Google-Attributes: gid103376,public From: Matthew Heaney Subject: Re: What's class? Date: 1999/02/24 Message-ID: #1/1 X-Deja-AN: 447745838 Sender: matt@mheaney.ni.net References: <7av8du$rjj$1@news.kornet.nm.kr> NNTP-Posting-Date: Tue, 23 Feb 1999 19:40:11 PDT Newsgroups: comp.lang.ada Date: 1999-02-24T00:00:00+00:00 List-Id: Rouault 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.