- Tech know how online


Literally, polymorphism means "many manifestations". The term is used for various manifestations of object-oriented programming languages.

  1. The property of variables to be able to take on different types.
  2. The property of functions to allow polymorphic arguments.
  3. The property of a function to be defined for different parameter sets with the same name.
  4. The property of an operator to refer to instances of different classes during runtime. Therefore, polymorphic messages are interpreted differently by different objects.

Programming languages are divided into two classes according to the role that typing plays there: statically and dynamically typed languages. Static means here that already at the program text - thus by the compiler - certain type information can be evaluated. In contrast, dynamic means here that only at runtime of the program the runtime system evaluates this type information.

In statically typed programming languages such as Pascal, Modula, the programming languages C++C++, a type is just assigned to the variables in an explicit declaration and determines how the value of a variable can be interpreted and manipulated. In dynamically typed programming languages such as Lisp and Smalltalk, this is just not the case. There, the type information is not stored with the variable declaration, but the value of a variable contains its type information. One consequence is that variables or function arguments can take values of different types during runtime and then be manipulated differently according to the value assignment.

Functions can now be programmed to perform different actions regardless of the typing of their arguments, e.g. "+" is defined differently on int arguments than on real arguments and returns different values of types as function values. Such variables, arguments and functions are called polymorphic (multiform).

Englisch: polymorphism
Updated at: 15.11.2009
#Words: 281
Links: object (O), parameter (PAR), name, operator, program
Translations: DE

All rights reserved DATACOM Buchverlag GmbH © 2024