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,FREEMAIL_FROM autolearn=ham autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,760a0492b97ae06e X-Google-Attributes: gid103376,public X-Google-ArrivalTime: 2003-12-22 09:33:47 PST Path: archiver1.google.com!news2.google.com!news.maxwell.syr.edu!newsfeed.mathworks.com!wn13feed!worldnet.att.net!216.166.71.14!border3.nntp.aus1.giganews.com!intern1.nntp.aus1.giganews.com!nntp.giganews.com!nntp.comcast.com!news.comcast.com.POSTED!not-for-mail NNTP-Posting-Date: Mon, 22 Dec 2003 11:33:46 -0600 Date: Mon, 22 Dec 2003 12:33:45 -0500 From: "Robert I. Eachus" User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.0; en-US; rv:1.4) Gecko/20030624 Netscape/7.1 (ax) X-Accept-Language: en-us, en MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: How to test object hierarchy References: <93172edb.0312181024.9a536b2@posting.google.com> <49cbf610.0312211158.87338af@posting.google.com> In-Reply-To: Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Message-ID: <84ednQiB4Y5nt3qiRVn-hQ@comcast.com> NNTP-Posting-Host: 24.34.214.193 X-Trace: sv3-3cL9a0gOd/YGsHV7xp5TGx1E2R6j0LIdTR2tDCn0hRyhU0bLiWw84c/ylEvl7SBaf1sx3BkajSGHGpU!6yzG96uIKy96WUAjJDT0vy+CMFLpTkXGWqf/bpWByAp1NGmDNjOuJalHigQ9bQ== X-Complaints-To: abuse@comcast.net X-DMCA-Complaints-To: dmca@comcast.net X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.1 Xref: archiver1.google.com comp.lang.ada:3702 Date: 2003-12-22T12:33:45-05:00 List-Id: Dmitry A. Kazakov wrote: > This is an argument in favor of implementing MD in Ada, I suppose (:-)) No, it is an argument that current Ada rules are just fine. You can do multiple dispatching in Ada, and the sort of casual dispatching where the author of the code doesn't even know that multiple dispatch is involves works just fine. For example, instantiate a generic with a classwide type or two as an actual type parameter. The resulting executable may have nested dispatching, but there is no real need to anticipate that case when writing the generic. As for cases where you really NEED to understand the code in multiple dispatching terms, these are no harder to program in Ada than in other languages--and no easier. And they really are that hard to wrap the mind around. There are cases which are worth the effort, but precious few. Another more prosaic example would be a general graphic file format converter. I can design such a tool as a combination of a reader and a writer with a standard intermediate representation: ... declare Temp: Intermediate_Format := Read(Input_File); begin Write(Temp, Output_File); end; Of course I can rewrite this as: Write(Read(Input_File), Output_File); Later I might want to add a graphics format that doesn't work well with the "standard" intermediate format. To do this, I can restructure the existing code with a multiple dispatch format: procedure Process(Input: in Graphics_Format; out Graphics_Format'Class); or function Process(Input: Graphics_Format) return Graphics_Format'Class; Now I can provide a body which normally uses the old approach with Intermediate_Format, but first checks for the special cases and handles them with other routines. THAT is when it starts to get difficult to use multiple dispatch. It is not the process of doing what I call 'casual' multiple dispatch in Ada, that is easy. The problem is going through on an N**2 case by case basis (or N**3 or N*M or whatever) and insuring that the approach that is dynamically selected for that particular case is, in some sense, the right one. And when the set of possibilities grows, adding one new format means considering 2N-1 new cases. -- Robert I. Eachus "The war on terror is a different kind of war, waged capture by capture, cell by cell, and victory by victory. Our security is assured by our perseverance and by our sure belief in the success of liberty." -- George W. Bush