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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,4d8b56262a702d36 X-Google-Attributes: gid103376,public From: "James A. Squire" Subject: Re: Dispatching in Ada95 Date: 1996/04/22 Message-ID: <317BCF1F.6542@csehp3.mdc.com>#1/1 X-Deja-AN: 150851532 sender: Ada programming language references: comments: Gated by NETNEWS@AUVM.AMERICAN.EDU content-type: text/plain; charset=us-ascii organization: MDA Avionics Tools & Processes mime-version: 1.0 newsgroups: comp.lang.ada x-mailer: Mozilla 2.01 (X11; I; HP-UX A.09.01 9000/715) Date: 1996-04-22T00:00:00+00:00 List-Id: On Fri, 19 Apr 1996 13:34:34, Samuel Tardieu wrote: > >>>>> "James" == James A Squire writes: > > James> Unless I am totally dense, in order for dispatching to work in > James> this example as printed on page II-8, there is one vital > James> element (which of course is left out of the example on II-8): > James> "use New_Alert_System; use Emergency_Alert_System;" > > James> Otherwise, dispatching doesn't work, because once the 'Class > James> attribute is used to figure out the actual type of the > James> Alert'Class parameter in a given instance, and then the Ada83 > James> rules kick in: check all overloaded subprograms _which are > James> directly visible_ at that point in time and pick the only one > James> that matches the parameter profile. > > I wouldn't say you're totally dense since I don't know you, but I > think you have misunderstood how dispatching works :) > > You're right in saying that it will check a subprogram which is > directly visible (if you don't give a prefix). But if your parameter > is of a class-wide type, only a subprogram with the base type of this > class-wide type needs to be visible. Correction: Directly visible. > Let's take an example. We create a package AAA which defines a class A > as well as a Create function, and a Get_Info function. [example snipped] > Now, our main procedure T. T withes AAA, BBB and Text_IO, and uses all > of them except BBB. So, you do compromise and use the use clause, then. That was my whole question. The use clause *is* essential to dispatching. Thank you for answering my question. Just another "gotcha" of Ada95 to note for future reference. -- James Squire MDA Avionics Tools & Processes ja_squire@csehp3.mdc.com "one of these days I'm going to better myself by going to Knight school" "You'll be a web knight instead of a web page!"