From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: Access types as parameters
Date: Sun, 16 Aug 2009 16:21:11 +0300
Date: 2009-08-16T16:21:11+03:00 [thread overview]
Message-ID: <4a8807d6$0$24780$4f793bc4@news.tdc.fi> (raw)
In-Reply-To: <mq2dep4cixt6.ct1n1x7rn2j3.dlg@40tude.net>
Dmitry A. Kazakov wrote:
> On Sun, 16 Aug 2009 12:52:53 +0300, Niklas Holsti wrote:
>
>> Are you saying that any inspection of the tag of an object is
>> "bad design", except for the case of "basic" dispatching?
>
> With a high degree of probability it is. In all cases I have to check tag I
> feel myself guilty.
Me too. But it is sometimes the best solution (in Ada 95 at least),
although it may cause maintenance problems.
>> Although I sometimes do it, I don't much like to inspect tags, as in Foo
>> above, because it couples the logic of a class-wide operation to the
>> existence and properties of certain explicitly named sub-classes, which
>> is fragile. But a redispatching call is not fragile in this way.
>
> It is fragile because it has a behavior that is not determined by the
> values attributed to the type T. Its behavior is determined by the values
> of T'Class, which is an open-ended set.
No. That argument makes *any* class-wide operation (using dispatching)
"fragile", because "its behaviour is determined by the open-ended set"
of operation implementations. We must accept this kind of "fragility" if
we use dispatching at all.
I persist in seeing no extra fragility in redispatching.
>>> Re-dispatch is a hack. What do you do is
>>> semantically not inheritance but overriding with an instance of a generic
>>> body, or some class-wide body. I think this is the key issue.
>> I'm sorry, I don't understand why it is "semantically not inheritance".
>
> Type S inherits F from T by composition of T.F with a type conversion:
>
> S.F = T.F o S_from_T
I think you have the conversion the wrong way around: If S.F should
apply to an object X of type S, then X must first be converted to T, and
then T.F applied:
S.F = T.F o T_from_S
meaning that
S.F (X) = T.F (T_from_S (X))
> That is the only way to define it in a typed language where S and T are
> distinct types. This is also how Ada defines it. Any primitive operation
> gets "re-declared" when you derive S from T.
Yes, yes, but Ada and other OO languages preserve the ability to
redispatch, which does not fit into this simple mathematical
functional-composition formalism. But then, we agreed that we use
different formalisms, so all is OK.
--
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
. @ .
next prev parent reply other threads:[~2009-08-16 13:21 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2009-07-17 8:39 Access types as parameters Rick
2009-07-17 15:03 ` Adam Beneschan
2009-07-17 16:28 ` Hibou57 (Yannick Duchêne)
2009-07-17 23:25 ` rickduley
2009-07-18 1:03 ` Randy Brukardt
2009-07-19 22:57 ` rickduley
2009-07-20 0:10 ` John B. Matthews
2009-07-20 8:13 ` Dmitry A. Kazakov
2009-07-21 0:34 ` Randy Brukardt
2009-07-21 14:34 ` Adam Beneschan
2009-07-23 2:11 ` Stephen Leake
2009-08-11 23:41 ` Randy Brukardt
2009-08-12 2:22 ` Stephen Leake
2009-08-13 1:06 ` Randy Brukardt
2009-08-13 8:34 ` Niklas Holsti
2009-08-13 9:15 ` Dmitry A. Kazakov
2009-08-13 20:13 ` Niklas Holsti
2009-08-13 21:07 ` Dmitry A. Kazakov
2009-08-14 9:27 ` Niklas Holsti
2009-08-14 10:36 ` Dmitry A. Kazakov
2009-08-14 16:03 ` Niklas Holsti
2009-08-15 9:47 ` Dmitry A. Kazakov
2009-08-15 19:19 ` Niklas Holsti
2009-08-16 8:32 ` Dmitry A. Kazakov
2009-08-16 9:52 ` Niklas Holsti
2009-08-16 12:38 ` Dmitry A. Kazakov
2009-08-16 13:21 ` Niklas Holsti [this message]
2009-08-16 17:58 ` Dmitry A. Kazakov
2009-08-14 4:07 ` Randy Brukardt
2009-08-14 10:22 ` Niklas Holsti
2009-08-18 12:22 ` 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