comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: What makes a procedure call 'dispatching' in Ada?
Date: Fri, 20 Nov 2009 19:44:26 +0100
Date: 2009-11-20T19:44:20+01:00	[thread overview]
Message-ID: <1qmblkmu03nzr$.1sobppq4k2gm0$.dlg@40tude.net> (raw)
In-Reply-To: 4b06af42$0$6292$4f793bc4@news.tdc.fi

On Fri, 20 Nov 2009 17:00:44 +0200, Niklas Holsti wrote:

> A better analogy is code like this:
> 
>     procedure John (X : Integer ..) is
>     begin
>        ...
>        if X /= 1 then ...
>        end if;
>        ...
>     end Jonh;
> 
>     procedure Mary (...) is
>     begin
>        if X = 1 then
>           John (X);
>        else ...
>        end if;
>     end Mary;

This is a wrong analogy. In your example John serves all values of X. So
when you call it with the value 1 it is not like dispatch, which chooses a
body for just one tag. In other words your example is an analogy to calling
a class-wide John from primitive Mary.

> Yes, there is a double check of X, but no, it is not a redundant check.

But with dispatch the check is redundant.

>> A technical issue is that if we had tagged types of value semantics (i.e.
>> classes rooted in Boolean, Integer etc), then re-dispatch could not work
>> with them.
> 
> Agreed, for pure value semantics. But "object identity" is a central 
> idea in object-oriented programming, so pure value semantics is doubtful 
> in this area.

Why is it doubtful? What is wrong with a class rooted in Boolean?

Anyway object identity, if any, is a domain space animal. The way by which
identity is modeled in the program is the programmer's business. You might
believe in the Platonic Universe where each number is unique with an RFID
chip on it, but that does not oblige you to use reference semantics for
integers.

>  > I.e. from Ada's agnostic point of view on by-value vs.
>  > by-reference, re-dispatch (or speaking more generally, view
>  > conversion to T'Class) is an implementation-specific kludge.
> 
> I think the parameter-passing method (by value or by reference) is not 
> the central question; the question is whether we have identifiable 
> objects or not. Objects could be passed by value, that is, the bits 
> representing the (view of the) object could be copied, but the "value" 
> would then have to include some kind of identity label (practically 
> speaking, a reference), which would allow redispatching.

You are conflating "values" of real world objects (modeled) and values of
the language objects (models). There is a mapping between them, but they
are different. Now, what you call identity is just a value (ID), which is
combined with another value (state). There is no mystery in it. You can
copy ID (like you can do the type tag). You can also copy the state (we
ignore here objects bound to hardware ports, random number generators etc).
This is what would happen if you passed a class-wide object by value. No
problem, and no need to re-dispatch, because no dispatch yet occurred. When
you pass only the state, you have to dispatch. Again, no mystery, you do
not lose the identity, it is now the calee's one. This identity in the
callee is statically known, though you might not know which callee among
many. Re-dispatching from a *given* callee is either redundant or worse, a
clash between the callee's identity and one of the actual object in the
caller. Some call it "type error"...

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



  reply	other threads:[~2009-11-20 18:44 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-11-20 13:15 What makes a procedure call 'dispatching' in Ada? Markus Schoepflin
2009-11-20  9:31 ` stefan-lucks
2009-11-20 14:10   ` Niklas Holsti
2009-11-20 13:27 ` Dmitry A. Kazakov
2009-11-20 13:43   ` Markus Schoepflin
2009-11-20 13:54     ` RasikaSrinivasan@gmail.com
2009-11-20 13:58     ` Markus Schoepflin
2009-11-20 14:19       ` Niklas Holsti
2009-11-21 14:07       ` Peter C. Chapin
2009-11-20 14:00     ` Niklas Holsti
2009-11-20 14:10     ` Dmitry A. Kazakov
2009-11-20 13:56 ` Niklas Holsti
2009-11-20 14:31   ` Dmitry A. Kazakov
2009-11-20 15:00     ` Niklas Holsti
2009-11-20 18:44       ` Dmitry A. Kazakov [this message]
2009-11-20 20:09         ` Niklas Holsti
2009-11-20 20:59           ` Dmitry A. Kazakov
2009-11-20 14:54 ` Ludovic Brenta
replies disabled

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