From: je@bton.ac.uk (John English)
Subject: Re: dispatching query
Date: 1998/02/04
Date: 1998-02-04T00:00:00+00:00 [thread overview]
Message-ID: <6b8c5m$8hb@saturn.brighton.ac.uk> (raw)
In-Reply-To: 34CFD22D.1D20CEA9@dsto.defence.gov.au
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
-----------------------------------------------------------------
next parent reply other threads:[~1998-02-04 0:00 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <34CFD22D.1D20CEA9@dsto.defence.gov.au>
1998-02-04 0:00 ` John English [this message]
1998-02-05 0:00 ` dispatching query Stephen Leake
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox