comp.lang.ada
 help / color / mirror / Atom feed
From: Niklas Holsti <niklas.holsti@tidorum.invalid>
Subject: Re: What makes a procedure call 'dispatching' in Ada?
Date: Fri, 20 Nov 2009 22:09:58 +0200
Date: 2009-11-20T22:09:58+02:00	[thread overview]
Message-ID: <4b06f7bd$0$6275$4f793bc4@news.tdc.fi> (raw)
In-Reply-To: <1qmblkmu03nzr$.1sobppq4k2gm0$.dlg@40tude.net>

Dmitry A. Kazakov wrote:
> 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.

You are not seeing the analogy that I intended. John does different 
things for certain values of X, similar to a primitive operation that is 
overridden for certain types (values of X when X is a tag).

> So when you call it with the value 1 it is not like dispatch, which
> chooses a body for just one tag.

The test "if X /= 1" in John is analogous to one dispatch, and the test 
"if X = 1" in Mary to another (perhaps it would have been clearer if the 
latter had been "if X > 2", or some other pair of less correlated 
checks). My point is that it is quite normal and valid to make several 
tests of the same value, as long as the tests are not redundant.

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

Obviously it is not, because the program behaves quite differently with 
redispatching than without it.

I grant you that for every program that uses redispatching there is an 
equivalent program that does not redispatch and computes the same thing. 
But I, personally, seem to find the redispatching program simpler to 
construct and understand. I also think it is usually shorter, with less 
almost-duplicated code.

I won't comment any more on the "object identity" question -- it becomes 
too philosophical for me (your reference to Plato motivates the use of 
this word :-). Redispatching is a well defined feature of current Ada 
that I find useful and not dangerous -- so far, at least.

-- 
Niklas Holsti
Tidorum Ltd
niklas holsti tidorum fi
       .      @       .



  reply	other threads:[~2009-11-20 20:09 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
2009-11-20 20:09         ` Niklas Holsti [this message]
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