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,f857f366542cd8aa X-Google-Attributes: gida07f3367d7,public,usenet X-Google-NewGroupId: yes X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news4.google.com!proxad.net!feeder1-2.proxad.net!usenet-fr.net!de-l.enfer-du-nord.net!news.weisnix.org!newsfeed.ision.net!newsfeed2.easynews.net!ision!newsfeed.arcor.de!newsspool4.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Sat, 11 Jul 2009 20:54:05 +0200 From: Georg Bauhaus Reply-To: rm.tsoh+bauhaus@maps.futureapps.de User-Agent: Thunderbird 2.0.0.22 (Windows/20090605) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Dispatch on the result still does not work? References: In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <4a58dfcf$0$30232$9b4e6d93@newsspool1.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 11 Jul 2009 20:54:07 CEST NNTP-Posting-Host: ac850fdc.newsspool1.arcor-online.net X-Trace: DXC=5j4jV<3gB]jOKO]LCQ@0g`ic==]BZ:afn4Fo<]lROoRa^YC2XCjHcbi[b9FcOG[i2lA:ho7QcPOVcZNiA8\2DX;aMmQY2X2_d6j X-Complaints-To: usenet-abuse@arcor.de Xref: g2news2.google.com comp.lang.ada:6995 Date: 2009-07-11T20:54:07+02:00 List-Id: Dmitry A. Kazakov wrote: > Considering this one: > I would expect it rather dispatching on the tag of X, i.e. selecting Value, > which returns S. > Another one, I don't like to call this a solution, and the running program differs per compiler used. But both compilers compile the units without errors: package P is type T is tagged null record; function Value return T; function Dispatched(X, V: T) return T'Class; type S is new T with null record; function Value return S; function Dispatched(X, V: S) return T'Class; end P; with Ada.Text_IO; package body P is function Dispatched(X, V: T) return T'Class is begin return V; end Dispatched; function Dispatched(X, V: S) return T'Class is begin return V; end Dispatched; function Value return T is begin Ada.Text_IO.Put_Line("Value returns a T"); return T'(null record); end Value; function Value return S is begin Ada.Text_IO.Put_Line("Value returns an S"); return S'(T with null record); end Value; end P; with P; procedure Run_P is use P; X: T'Class := S'(Value); begin X := Dispatched(X, Value); end Run_P;