comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: What's class?
Date: 1999/02/25
Date: 1999-02-25T00:00:00+00:00	[thread overview]
Message-ID: <m3sobu3k90.fsf@mheaney.ni.net> (raw)
In-Reply-To: 7avvpf$pfl@drn.newsguy.com

bill <bill@newsguy.com> 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.

<http://www.acm.org/archives/patterns.html>



  










  parent reply	other threads:[~1999-02-25  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
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 [this message]
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