From: Maciej Sobczak <no.spam@no.spam.com>
Subject: Re: Generic procedures and their parameters
Date: Fri, 08 Sep 2006 11:11:35 +0200
Date: 2006-09-08T11:11:35+02:00 [thread overview]
Message-ID: <edrc48$nfa$1@sunnews.cern.ch> (raw)
In-Reply-To: <15ibl2xejtc68.1eg90p1fwn18p$.dlg@40tude.net>
Dmitry A. Kazakov wrote:
>> In C++ the fact
>> that int is ordered does not require that it relates to some Ordered
>> class.
>
> Which is unfortunate for both C++ and Ada, because "to be ordered" = "a
> member of Ordered class." There is no obvious reason why they should be
> different.
No obvious, but subtle, yes.
Integer is Ordered, but so is String. Can you imagine a
Sequence_Of_Ordered containing, say, 7, 123, "Dmitry", -5, "Maciej"?
All these objects are Ordered. Just like Banana is Fruit and Apple is
Fruit, right? Still, I can imagine a container of Fruits with Bananas
mixed with Apples, but certainly not a container of Ordered - and the
problem is that the values listed above don't really share much in
common. Can you sort a Sequence_Of_Ordered? No.
So - what does it really mean that Integer and String are both Ordered?
OK, I know - we forgot that their "domains" of ordering are disjoint.
But then - what's the point of having Ordered'Class?
As far as I perceive it, the fact that Banana is Fruit and the fact that
Integer is Ordered are two facts of *different kind*. The former is
related to the "business disctionary" (nice buzz), whereas the latter is
more an information about the type. For me, these two facts exist on
separate levels and should not be mixed in the same inheritance
hierarchy. Moreover, the language should give me distinct tools to
express these distinct kinds of facts and for example in C++ I use class
inheritance for Banana is Fruit, but type traits for Integer is Ordered.
If I had to express these two in the same way (and in the same
hierarchy) I would feel a bit uncomfortable. Kind of "weak type safety
on the meta-level".
There is another "small issue". Robert mentioned that trees are
aesthetically pleasing. The problem is that with Ordered (Comparable,
Summable, etc.) there is no tree any more because of massive
proliferation of multiple inheritance that is then used to express facts
about types. The only "pleasing" thing left in the resulting mess is
that there are still no cycles. ;-)
--
Maciej Sobczak : http://www.msobczak.com/
Programming : http://www.msobczak.com/prog/
next prev parent reply other threads:[~2006-09-08 9:11 UTC|newest]
Thread overview: 27+ messages / expand[flat|nested] mbox.gz Atom feed top
2006-09-06 8:51 Generic procedures and their parameters Maciej Sobczak
2006-09-06 9:43 ` Dmitry A. Kazakov
2006-09-06 12:36 ` Maciej Sobczak
2006-09-06 13:11 ` Robert A Duff
2006-09-06 14:14 ` Maciej Sobczak
2006-09-06 15:09 ` Dmitry A. Kazakov
2006-09-06 16:35 ` Georg Bauhaus
2006-09-07 7:32 ` Dmitry A. Kazakov
2006-09-07 6:48 ` Georg Bauhaus
2006-09-07 10:19 ` Dmitry A. Kazakov
2006-09-08 9:11 ` Maciej Sobczak [this message]
2006-09-08 10:19 ` Dmitry A. Kazakov
2006-09-09 14:49 ` Robert A Duff
2006-09-09 15:34 ` Dmitry A. Kazakov
2006-09-09 23:26 ` Jeffrey R. Carter
2006-09-10 11:49 ` Robert A Duff
2006-09-10 19:43 ` Jeffrey R. Carter
2006-09-06 13:02 ` Robert A Duff
2006-09-06 14:09 ` Dmitry A. Kazakov
2006-09-08 3:35 ` Randy Brukardt
2006-09-08 7:21 ` Dmitry A. Kazakov
2006-09-09 1:29 ` Randy Brukardt
2006-09-09 7:14 ` Dmitry A. Kazakov
2006-09-09 14:32 ` Robert A Duff
2006-09-06 12:56 ` Robert A Duff
2006-09-07 2:47 ` Steve
2006-09-07 7:47 ` 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