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,24c2bbee2aceff98 X-Google-Attributes: gid103376,public From: mheaney@ni.net (Matthew Heaney) Subject: Re: Ada 95 dispatching question Date: 1997/11/26 Message-ID: #1/1 X-Deja-AN: 293054393 References: <880581829.29833@dejanews.com> Organization: Estormza Software Newsgroups: comp.lang.ada Date: 1997-11-26T00:00:00+00:00 List-Id: In article <880581829.29833@dejanews.com>, adam@irvine.com (Adam Beneschan) wrote: >with text_io; >package body pack2 is > > procedure do_to_aux (a : in auxinfotype2) is > begin > text_io.put ("???"); > end do_to_aux; > > procedure do_to_rec (r : in pack1.rectype) is > begin > text_io.put (integer'image (r.f1) & "/" & boolean'image (r.f2) & > "/"); > do_to_aux (auxinfotype2 (r.f3.all)); -- <=== HERE > text_io.new_line; > end do_to_rec; > >end pack2; No, the marked line is NOT a dispatching call. You downcasted the root type to a specific type - not a classwide type - and so do_to_aux binds statically, to the version for auxinfotype2. The rule in Ada is, you only dispatch on an object whose type is T'Class. Had you downcasted to the classwide type auxinfotype2'Class, ie do_to_aux (auxinfotype2'Class (r.f3.all)); then dispatching would occur. -------------------------------------------------------------------- Matthew Heaney Software Development Consultant (818) 985-1271