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,start X-Google-Attributes: gid103376,public From: "James A. Squire" Subject: Dispatching in Ada95 Date: 1996/04/18 Message-ID: <3176FEBF.5D3@csehp3.mdc.com>#1/1 X-Deja-AN: 148292784 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-18T00:00:00+00:00 List-Id: I'm told that in object oriented programming like C++, one of the nice aspects of the language is that dispatching occurs based on the object instance that is being used - that in fact the method is prefixed by the object instance and that is all it takes to find the code that needs to be executed. Look at the Ada95 Rationale, especially with respect to the New_Alert_System example on page II-6 and the extension Emergency_Alert_System on II-7, Class Wide programming is presented as the way in which dispatching is implemented. Unless I am totally dense, in order for dispatching to work in this example as printed on page II-8, there is one vital element (which of course is left out of the example on II-8): "use New_Alert_System; use Emergency_Alert_System;" Otherwise, dispatching doesn't work, because once the 'Class attribute is used to figure out the actual type of the Alert'Class parameter in a given instance, and then the Ada83 rules kick in: check all overloaded subprograms _which are directly visible_ at that point in time and pick the only one that matches the parameter profile. Without the use clauses, I presume something nasty like Program_Error would be raised. How do people handle this? I'm curious, especially since type extension is intended to be possible without having to recompile the original package. Do you corrupt your application by using the use clause? Or do you work around this problem some other way? Or am I missing something? -- 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!"