comp.lang.ada
 help / color / mirror / Atom feed
From: Matthew Heaney <matthew_heaney@acm.org>
Subject: Re: Help - Constructors - ASAP.
Date: 1998/08/05
Date: 1998-08-05T00:00:00+00:00	[thread overview]
Message-ID: <m3iuk8mvts.fsf@mheaney.ni.net> (raw)
In-Reply-To: 35C750F2.483B5A51@elca-matrix.ch

Mats Weber <Mats.Weber@elca-matrix.ch> writes:
> > Ah, but then another rule of thumb applies.  Since the generic operation
> > isn't primitive anyway, you just make the tagged parameters class-wide.
> > Then it will work for your derived types too.
> 
> Weren't we talking about non-tagged types ?

I thought tagged types.  At least some of the discussion on this thread
concerned whether have the constructor return the class-wide vs specific
type. 
 
> Anyway, I don't think it's a good idea to make them class-wide just
> for that reason. Most often, the generic operation needs to be adapted
> when inheriting, so making the tagged type parameters class-wide is
> error-prone.

Then we disagree.  If we're talking about a hierarchy of tagged types,
then there's not much difference between declaring a primitive operation
of the parent type that is automatically inherited by the derived type,
and manually renaming a generic operation that takes the parent
class-wide type.

Don't forget the example: we were deriving from the parent type by
adding a null extension, to get direct visibility of the type in a
different scope.  The types are otherwise identical.  So I don't accept
your argument that making the generic operation is error-prone, because
it's basically the same type.

Anyway, shouldn't an operation inherited from the parent always be
guaranteed to work in the derived type?  If there is an inherited
operation that wouldn't work in the derived type, then it's the
responsibility of the derived type to override the operation so that it
does work.

Ditto for parent generic operations that take the parent class-wide
type.  If the operation will work in the derived type, then the derived
type can safely rename the parent's generic operation.  If the operation
wouldn't work, then it is of course the responsibility of the derived
type to "override" the generic parent operation by providing another.

There is nothing special about the a parent operation being generic,
except that (I think) you should declare the operation to take
class-wide parameters, in order to simplify the life of programmer
writing the derived type.  (And to simplify the clients of the derived
type, who will then have visibility to all the operations, including
generic ones).

Issues about correctness or error-proneness apply equally, whether the
operation is inherited, or a renaming of a generic operation.






  reply	other threads:[~1998-08-05  0:00 UTC|newest]

Thread overview: 26+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1998-07-23  0:00 Help - Constructors - ASAP Maxim Senin
1998-07-26  0:00 ` Matthew Heaney
1998-07-27  0:00   ` dennison
1998-07-30  0:00     ` Robert I. Eachus
1998-07-30  0:00       ` tedennison
1998-07-31  0:00         ` Matthew Heaney
1998-07-31  0:00         ` Mats Weber
1998-07-31  0:00           ` Robert I. Eachus
1998-08-01  0:00             ` Matthew Heaney
1998-07-31  0:00           ` dennison
1998-08-01  0:00             ` Robert Dewar
1998-08-01  0:00               ` Matthew Heaney
1998-08-01  0:00             ` Matthew Heaney
1998-08-03  0:00             ` Mats Weber
1998-08-01  0:00       ` Robert Dewar
1998-08-01  0:00         ` Matthew Heaney
1998-08-03  0:00           ` Mats Weber
1998-08-03  0:00             ` Matthew Heaney
1998-08-03  0:00               ` Mats Weber
1998-08-04  0:00                 ` Matthew Heaney
1998-08-04  0:00                   ` Mats Weber
1998-08-05  0:00                     ` Matthew Heaney [this message]
1998-08-10  0:00           ` Robert I. Eachus
1998-08-03  0:00         ` tedennison
  -- strict thread matches above, loose matches on Subject: below --
1998-07-15  0:00 Maxim Senin
1998-07-16  0:00 ` Stephen Leake
replies disabled

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