From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Thread: a07f3367d7,366b213c4abb1039 X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news1.google.com!news3.google.com!feeder1-2.proxad.net!proxad.net!feeder2-2.proxad.net!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail From: "Dmitry A. Kazakov" Subject: Re: What makes a procedure call 'dispatching' in Ada? Newsgroups: comp.lang.ada User-Agent: 40tude_Dialog/2.0.15.1 MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Reply-To: mailbox@dmitry-kazakov.de Organization: cbb software GmbH References: <4b06a048$0$26319$4f793bc4@news.tdc.fi> <1ced67sbv38ke.1973smwq7n0uw.dlg@40tude.net> <4b06af42$0$6292$4f793bc4@news.tdc.fi> Date: Fri, 20 Nov 2009 19:44:26 +0100 Message-ID: <1qmblkmu03nzr$.1sobppq4k2gm0$.dlg@40tude.net> NNTP-Posting-Date: 20 Nov 2009 19:44:20 CET NNTP-Posting-Host: 42bc62bf.newsspool4.arcor-online.net X-Trace: DXC=CiL3\BjVM\3lIh70@[V?m0 X-Complaints-To: usenet-abuse@arcor.de Xref: g2news1.google.com comp.lang.ada:8179 Date: 2009-11-20T19:44:20+01:00 List-Id: 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