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=unavailable autolearn_force=no version=3.4.4 Path: buffer1.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!border2.nntp.dca1.giganews.com!nntp.giganews.com!usenet.blueworldhosting.com!feeder01.blueworldhosting.com!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!news-1.dfn.de!news.dfn.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail From: Niklas Holsti Newsgroups: comp.lang.ada Subject: Re: Trouble with "operation can be dispatching in only one type" Date: Wed, 13 Aug 2014 23:01:42 +0300 Organization: Tidorum Ltd Message-ID: References: Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit X-Trace: individual.net EeocNPtf+6yPN3AyC+Y73QpzchakC/LAVr3uXJXL/n407bjSiK Cancel-Lock: sha1:teEjL4ZueNx7txxLPaYeX/5BBmk= User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.8; rv:24.0) Gecko/20100101 Thunderbird/24.6.0 In-Reply-To: Xref: number.nntp.dca.giganews.com comp.lang.ada:188435 Date: 2014-08-13T23:01:42+03:00 List-Id: On 14-08-13 22:23 , Victor Porton wrote: > I defined two tagged types T1 and T2 in some package. > > I need a function in the same package: > > not overriding function F (Stack: T1) return T2; > > The compiler complaints: > > operation can be dispatching in only one type > > My current workaround is to define it instead as: > > not overriding function F (Stack: T1'Class) return T2; > > But this is a hack. Can I define this function in the right way? (I want it > to be dispatching only in T1, not T2.) To be dispatching in T1, but not in T2, it should be function F (Stack : T1) return T2'Class; If the use of 'Class to prevent dispatching is a problem for you, another way is to put the two type declarations in different packages. A function F can be dispatching only in the type declared in the same package as F. For example, if T2 is declared in a different package than T1 (including a package nested within the package that declares T1) then you can declare function F (Stack : T1) return Some_Pkg.T2 and it will dispatch only in T1 (assuming that T1 and F are declared in the same package declaration). -- Niklas Holsti Tidorum Ltd niklas holsti tidorum fi . @ .