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/25 Message-ID: #1/1 X-Deja-AN: 448243227 Sender: matt@mheaney.ni.net References: <7av8du$rjj$1@news.kornet.nm.kr> <7avvpf$pfl@drn.newsguy.com> NNTP-Posting-Date: Thu, 25 Feb 1999 01:25:23 PDT Newsgroups: comp.lang.ada Date: 1999-02-25T00:00:00+00:00 List-Id: bill writes: > Since any type that extends a parent type, also inherits its operations, > then in this case, writing > > function is_full( stack: in bounded_stack'class) > and > function is_full( stack: in bounded_stack) > > > make no difference! > > correct? Not quite. That would only be true if the derived type didn't override the Is_Full operation. The purpose in making it primitive (instead of class-wide) is to allow the derived type to override the operation. A class-wide operation is not override-able. There's also a name-space issue. Primitive operations of the derived type are implicitly declared at the point of derivation. However, a class-wide operation isn't inherited, and so does not exist where the (derived) type is (unless of course the derivation is in the same package as the class-wide operation). In your example above, you wouldn't get an Is_Full operation at the same place as the (derived) type, and you'd have to go back to the original package in which the Is_Full operation is declared, in order to use it. In the pattern community, class-wide operations are called "template methods." You can read all about the finer points of template method patterns in Ada95 by reading the Template Method post in the June 98 patterns archive at the ACM.