From: John English <je@bton.ac.uk>
Subject: Re: Run Time Dispatch Question
Date: 2000/02/25
Date: 2000-02-25T13:25:25+00:00 [thread overview]
Message-ID: <38B6837E.7208F8C8@bton.ac.uk> (raw)
In-Reply-To: 895q4e$5up$1@ssauraaa-i-1.production.compuserve.com
Michael Garrett wrote:
> I am having a problem understanding run time dispatching. ( Basic question I
> know, but I'm having a brain cramp. )
> [...snip...]
You need to put your tagged type t and primitive p in a package, not
a procedure. Otherwise, the procedure p(...) defined for each type
derived from t is just an overload of the name p, not a primitive of
the type. Dispatching only happens for primitives. To quote RM95
3.2.3:
The primitive subprograms of a specific type are defined as
follows:
a) The predefined operators of the type (see 4.5);
b) For a derived type, the inherited (see 3.4) user-defined
subprograms;
c) For an enumeration type, the enumeration literals (which are
considered parameterless functions -- see 3.5.1);
d) For a specific type declared immediately within a
package_specification, any subprograms (in addition to the
enumeration literals) that are explicitly declared immediately
within the same package_specification and that operate on
the type;
e) Any subprograms not covered above that are explicitly declared
immediately within the same declarative region as the
type and that override (see 8.3) other implicitly declared
primitive subprograms of the type.
So, if t and p were declared in a package then p would be a primitive
(by (d)), and overloading p for t1 and t2 would make them primitives
too (by (e)).
-----------------------------------------------------------------
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 prev parent reply other threads:[~2000-02-25 0:00 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2000-02-25 0:00 Run Time Dispatch Question Michael Garrett
2000-02-25 0:00 ` John English [this message]
2000-02-26 0:00 ` Michael Garrett
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox