comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Access types as parameters
Date: Sun, 16 Aug 2009 19:58:12 +0200
Date: 2009-08-16T19:58:08+02:00	[thread overview]
Message-ID: <jxv4k441vju4.15ifr6t7ef19w.dlg@40tude.net> (raw)
In-Reply-To: 4a8807d6$0$24780$4f793bc4@news.tdc.fi

On Sun, 16 Aug 2009 16:21:11 +0300, Niklas Holsti wrote:

> Dmitry A. Kazakov wrote:
>> On Sun, 16 Aug 2009 12:52:53 +0300, Niklas Holsti wrote:
>> 
>>> 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.

The fragility is not in the set size, but in the operation that handles it
implicitly. It is like with side effects. You do one thing, but rely on
more than that. Dispatching on the context of the type T it is fragile. On
the context of T'Class it is not.

>>>> 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

Yes.

> meaning that
> 
>     S.F (X) = T.F (T_from_S (X))

Right.

>> 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.

Simple or complex I didn't see different formalisms, that don't fall apart
when classes of built-in types come into consideration. Everything is
reference? Is reference a reference? etc. And even if re-dispatch could be
reconciled with strog typing, an aftertaste remains, to do same thing twice
looks wrong.

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



  reply	other threads:[~2009-08-16 17:58 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
2009-08-16 17:58                                               ` Dmitry A. Kazakov [this message]
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