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,47def5aa7b3182bd X-Google-Attributes: gid103376,public From: Matthew Heaney Subject: Re: How to write TYPECASE in Ada 95? Date: 1999/02/06 Message-ID: #1/1 X-Deja-AN: 441459938 Sender: matt@mheaney.ni.net References: <79fct8$9k3$1@murdoch.acc.Virginia.EDU> <0JJEkbcU#GA.219@pet.hiwaay.net> NNTP-Posting-Date: Sat, 06 Feb 1999 12:59:05 PDT Newsgroups: comp.lang.ada Date: 1999-02-06T00:00:00+00:00 List-Id: Matthew Heaney writes: > with Points; use Points; > procedure Test_Points is > begin > > declare > P : Tall_Point := (3.0, 4.0, 5.0); > begin > Points.Show_Type (P); > Points.Show_Properties (Point'Class (P)); > end; > > declare > P : Painted_Point := (3.0, 4.0, Points.Blue); > begin > Points.Show_Type (P); > Points.Show_Properties (Point'Class (P)); > end; > > end Test_Points; I should have pointed out that you don't actually need to dispatch Show_Properties. At the invocation, you know the specific type of the point, so why convert it to the class-wide type? procedure Test_Points is begin declare P : Tall_Point := (3.0, 4.0, 5.0); begin Points.Show_Type (P); Points.Show_Properties (P); end; declare P : Painted_Point := (3.0, 4.0, Points.Blue); begin Points.Show_Type (P); Points.Show_Properties (P); end; end Test_Points; The object model of Ada95 was designed to allow the caller to choose whether dispatching occurs. All the calls in the example above are static, which is all they need to be.