comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: tagged type as generic parameter
Date: Thu, 3 Jan 2008 17:58:01 +0100
Date: 2008-01-03T17:58:04+01:00	[thread overview]
Message-ID: <17k6uddmxknzi$.1q1crpca0ygrf.dlg@40tude.net> (raw)
In-Reply-To: 602e79cf-755f-4600-a2cd-0cabf781136a@e25g2000prg.googlegroups.com

On Thu, 3 Jan 2008 08:22:24 -0800 (PST), Adam Beneschan wrote:

> On Jan 3, 7:51 am, "Dmitry A. Kazakov" <mail...@dmitry-kazakov.de>
> wrote:
> 
>> 3. Aggregation instead of inheritance:
>>
>>    type Item is record
>>       Next  : Item_Ptr;
>>       Value : Data;
>>    end record;
>>
>> No inheritance, no problem.
> 
> Actually, I think the OP really needs a darn good reason why he would
> want Item to be inherited from his generic formal type, rather than
> simply a record containing a value and a link as in your above
> suggestion.  Conceptually, at least to me, a type extension is
> supposed to define a type that is a "kind of" the parent type.  In
> this case, Item, as the OP originally defined it, doesn't really fit
> the concept.  It's not really a "kind of" Data with additional
> properties.  I'm sorry that my "pedagogical" understanding of object-
> oriented programming isn't solid enough that I understand what terms
> to use, but hopefully I'm getting some sort of notion across.

A reason might be to be able to use list items and their content
interchangeably, another could be to handle unconstrained data.

However, these are certainly not the case for the OP's code. Because Item
is private there and Data is constrained. And even if Item were visible,
then the right way would likely be #2, because "anything tagged" as in OP's
code does not tell much about the inherited semantics of list elements.

IMO, your understanding of OOP is quite right.

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2008-01-03 16:58 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-01-03 15:20 tagged type as generic parameter Philippe Tarroux
2008-01-03 15:51 ` Dmitry A. Kazakov
2008-01-03 16:22   ` Adam Beneschan
2008-01-03 16:58     ` Dmitry A. Kazakov [this message]
2008-01-03 17:47       ` Jean-Pierre Rosen
2008-01-03 18:13         ` Pascal Obry
2008-01-03 19:20         ` Dmitry A. Kazakov
2008-01-03 21:37         ` Jeffrey R. Carter
2008-01-04 13:08           ` Philippe Tarroux
2008-01-04 15:03             ` Jean-Pierre Rosen
2008-01-04 13:08   ` Philippe Tarroux
2008-01-04 13:22     ` Georg Bauhaus
2008-01-04 15:38       ` Philippe Tarroux
2008-01-04 14:17     ` Dmitry A. Kazakov
replies disabled

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