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,d584bc664c4c7293,start X-Google-Attributes: gid103376,public From: je@bton.ac.uk (John English) Subject: Re: dispatching query Date: 1998/02/04 Message-ID: <6b8c5m$8hb@saturn.brighton.ac.uk>#1/1 X-Deja-AN: 321888665 References: <34CFD22D.1D20CEA9@dsto.defence.gov.au> Organization: University of Brighton Newsgroups: comp.lang.ada Date: 1998-02-04T00:00:00+00:00 List-Id: Mark Rutten (Mark.Rutten@dsto.defence.gov.au) wrote: : Is it only possible to dispatch on subprograms which can be inherited : (i.e. specified in the same declarative block)? You're talking about primitives. Dispatching happens when you have a class wide type (X'Class). : package messages is : type message is abstract tagged null record; : type message_ptr is access all message'Class; : procedure copy(msg: access message) is abstract; : end messages; : Then (in some other package) I declare a type (or several types) which : extend message. What I would like to do is to define a set of procedures : in a third package (separate to the declarations of the types) which can : be dispatched upon : e.g. : procedure handle(msg: access boolean_message); : procedure handle(msg: access integer_message); So, make handle a primitive of Message (abstract if necessary) and then hand it a class-wide pointer (an access Message'Class) to make it dispatch. That is, add procedure Handle (Msg : access Message) is abstract; to Messages, and then call Handle(This_Message'Access) (where This_Message is a Message'Class object). ----------------------------------------------------------------- John English | mailto:je@brighton.ac.uk Senior Lecturer | http://www.it.bton.ac.uk/staff/je Dept. of Computing | ** NON-PROFIT CD FOR CS STUDENTS ** University of Brighton | -- see http://burks.bton.ac.uk -----------------------------------------------------------------