Re: What is polymorphism?
- From: "Dmitry A. Kazakov" <mailbox@xxxxxxxxxxxxxxxxx>
- Date: Wed, 7 Jun 2006 14:48:24 +0200
On Wed, 07 Jun 2006 14:21:14 +0200, bruno at modulix wrote:
Daniel T. wrote:
More
specifically, it is the ability to redefine methods for derived classes.
And this is very specific to declarative statically typed languages. In
dynamically typed languages or languages with type-inference, there's
just no need for "redefining" nor "derived classes" - as long as an
object understand the message (which, for some languages, doesn't even
imply the object's classes and/or superclasses define a corresponding
method), it's ok.
It is not statically specific. Class is defined as all objects that
"understand." An ability to redefine is imprecise. Better would be to say:
an ability to define methods of a class in terms of methods of individual
types.
For example, given a base class shape, polymorphism enables the
programmer to define different area methods for any number of derived
classes, such as circles, rectangles and triangles.
Here again, it's somehow declarative-static-typing specific. The base
class is only here to satisfy compiler requirements wrt/ typing.
No, it is to describe the class of types. Polymorphism is an ability to
deal with sets of types. Class is one way of doing this. In the class one
of the types of, is the base type. In a loosely typed dynamical language,
you describe, there is only one class, which allows to send messages
arbitrarily. This requires any object to respond to anything. Which is
achieved by replying to each message with "What? Go away!"
More advanced type systems allow user-defined classes, which serve as a
"spam filter."
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
.
- Follow-Ups:
- Re: What is polymorphism?
- From: bruno at modulix
- Re: What is polymorphism?
- References:
- What is polymorphism?
- From: Seigfried
- Re: What is polymorphism?
- From: Daniel T.
- Re: What is polymorphism?
- From: bruno at modulix
- What is polymorphism?
- Prev by Date: Re: What is polymorphism?
- Next by Date: Re: What is polymorphism?
- Previous by thread: Re: What is polymorphism?
- Next by thread: Re: What is polymorphism?
- Index(es):
Relevant Pages
|