From: Adam Beneschan <adam@irvine.com>
Subject: Re: tagged type as generic parameter
Date: Thu, 3 Jan 2008 08:22:24 -0800 (PST)
Date: 2008-01-03T08:22:24-08:00 [thread overview]
Message-ID: <602e79cf-755f-4600-a2cd-0cabf781136a@e25g2000prg.googlegroups.com> (raw)
In-Reply-To: xgdnrdjferbj.nn9l327fp4xn.dlg@40tude.net
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.
Or, to put it another way, don't use type extensions just because
they're there.
To me, #3 stands out as the *correct* solution to the problem, in most
cases. Plus, if you do that, Data no longer needs to be a tagged
formal type, so that you can use your generic on both tagged and
untagged types.
-- Adam
next prev parent reply other threads:[~2008-01-03 16:22 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 [this message]
2008-01-03 16:58 ` Dmitry A. Kazakov
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