[comp.object] Class information at run time in OOPLs

plogan@mentorg.com (Patrick Logan) (01/19/91)

A letter in the ACM Forum, CACM 1/91, states that "most" OOPLs lack
the ability to test class membership at run time. The letter then
mentions C++ as such a language.

I would guess the opposite, that most OOPLs retain class information
at run time. Which other (widely known) OOPLs lack this feature?
Eiffel, I think. Any others?

(Of course, there are various ways to maintain or determine class
membership in C++, but the language itself does not specify one.)

-- 
Patrick Logan, uunet!mntgfx!plogan -or- plogan@dad.mentor.com
Mentor Graphics Corp. 8500 SW Creekside, Beaverton, Oregon 97005-7191

rick@tetrauk.UUCP (Rick Jones) (01/21/91)

In article <1991Jan18.215348.6161@mentorg.com> plogan@mentorg.com (Patrick Logan) writes:
>A letter in the ACM Forum, CACM 1/91, states that "most" OOPLs lack
>the ability to test class membership at run time. The letter then
>mentions C++ as such a language.
>
>I would guess the opposite, that most OOPLs retain class information
>at run time. Which other (widely known) OOPLs lack this feature?
>Eiffel, I think. Any others?
 ^^^^^^

I would like to correct this statement - Eiffel does NOT lack the ability to
test class membership at run-time.  The method used may be described as
"type-safe reverse assignment".  The syntax is

	x ?= y ;

where x and y are class-type variables.  If the object attached to y is of a
type conformant to the declared type of x (i.e. the same class or a
descendant), the assignment succeeds.  If not, x becomes a void reference.
This is a very simple but powerful solution to the problem.

It was only introduced in version 2.2 (the current version is now 2.3), so
those whose knowledge is not up to date can be forgiven for not being aware of
it :-).

-- 
Rick Jones
Tetra Ltd.  Maidenhead, 	Was it something important?  Maybe not
Berks, UK			What was it you wanted?  Tell me again I forgot
rick@tetrauk.uucp					-- Bob Dylan