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=-1.9 required=5.0 tests=BAYES_00 autolearn=ham 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!feeder.news-service.com!newsfeed101.telia.com!nf02.dk.telia.net!news.tele.dk!news.tele.dk!small.news.tele.dk!fi.sn.net!newsfeed2.fi.sn.net!news.song.fi!not-for-mail Date: Fri, 20 Nov 2009 22:09:58 +0200 From: Niklas Holsti Organization: Tidorum Ltd User-Agent: Mozilla-Thunderbird 2.0.0.22 (X11/20090706) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: What makes a procedure call 'dispatching' in Ada? References: <4b06a048$0$26319$4f793bc4@news.tdc.fi> <1ced67sbv38ke.1973smwq7n0uw.dlg@40tude.net> <4b06af42$0$6292$4f793bc4@news.tdc.fi> <1qmblkmu03nzr$.1sobppq4k2gm0$.dlg@40tude.net> In-Reply-To: <1qmblkmu03nzr$.1sobppq4k2gm0$.dlg@40tude.net> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <4b06f7bd$0$6275$4f793bc4@news.tdc.fi> NNTP-Posting-Host: 81.17.205.61 X-Trace: 1258747837 news.tdc.fi 6275 81.17.205.61:52918 X-Complaints-To: abuse@tdcnet.fi Xref: g2news1.google.com comp.lang.ada:8180 Date: 2009-11-20T22:09:58+02:00 List-Id: 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 . @ .