FidoNet Echomail Archive

<<< Previous Index Next >>>

From: Bill Birrell
To: Neil Heller
Date: 2004-07-13 15:31:00
Subject: Polymorphism ?

Hi Neil,

 > In C, does a cast from type void to a pointer to type
 > char show a type
 > of polymorphism?  The easy answer is "no" because the
 > C language make no
 > mention whatsoever of the concept of polymorphism.
 > This aside, however,
 > might it be considered the start toward polymorphism?

    No. C really isn't polymorphic. C++ can be.

 > BB>    Let me illustrate: You and your dog are the same type
 > BB> of animal - you are mammals. However your form is human
 > BB> while your dog's form is canine. Does this clarify, or only
 > BB> confuse?

 > A dog and an alligator are also the same type of
 > animal - they are both
 > quadrupeds.

    However one is a mammal and the other is an amphibian. That makes them
utterly different types. Bad example, Neil. Having four legs is form or
shape, not type.

    This is the same confusion between type and form as before. Until you
grasp that polymorphism has to do with multiple forms or shapes (or
geometry if you prefer) you will not understand it. It is not related to
types, not even user defined types.

 > Are you saying that at some level of existence everything is
 > essentially the
 > same (keeping the prime elements of air, earth, fire
 > and water separate,
 > of course)?

    Again, no. All elements have in theory three forms, solid, liquid and
gas. That's as far as it goes. Some things are naturally polymorphic (like
carbon) some aren't. Usually it is not an important attribute. Why is it so
important to you?

 > Was the original idea of a cast initially a concept
 > that came from Merlin?

    No. It came from the ANSI committee. Before that casts were largely
unnecessary. BCPL was loosely typed and K&R C inherited that
loosesness. It even had a default type - int.

    ANSI C got rid of that looseness with a vengeance. That made casts necessary.

    I take it you mean Merlin of the long beard and pointy hat? :-)

Best Wishes,

 * Origin: Escan BBS (2:25/200)
SEEN-BY: 633/267 270
@PATH: 25/200 108 252/110 250/501 140/1 106/2000 633/267

<<< Previous Index Next >>>