Map
Index
Random
Help
Topics
th

Topic: generic operations and polymorphism

topics > computer science > programming > object-oriented programming > Group: type inheritance



Group:
data type

Topic:
abstract data type
Topic:
abstract functions
Topic:
automatic selection of algorithm for abstract data type
Topic:
data type as a set of operations
Topic:
data type as constructors, selectors, and predicates
Topic:
dynamic vs. static data type
Topic:
early vs. late binding
Topic:
function signature
Topic:
interface type
Topic:
language flexibility
Topic:
macros
Topic:
non-exclusive data type
Topic:
object-oriented methods
Topic:
object-oriented templates and containers
Topic:
scripting language
Topic:
type parameter
Topic:
union data type

Summary

The same operator name may be applied to different operand types resulting in "polymorphic" or "overloaded" functions. Generic selection is selecting the correct function depending on the operand types. Languages where the operand's types are part of the function's name, do not need generic selection. Generic selection is most widely used with arithmetic operations, since each operator has a mathematical meaning. For instance '+' is the mathematical addition operator but '+' operating on integers has a different implementation than '+' operating on reals. (cbb 5/80)

A generic operation is a kind of syntactic abstraction formed by removing all type information from a program. It implies that operations with the same name have the same semantic properties. This may or may not be true. (cbb 1/90)

Subtopic: fundamental operations up

Quote: the fundamental operations of type T are constructors, destructors, assignment, equality, and ordering [»dehnJC4_1998]
Quote: Sketchpad includes general functions that are independent of type; e.g., expand an instance of a subpicture; powerful [»suthIE5_1963]
Quote: Sketchpad provides general functions for expansion of instances, recursive deletion, and recursive merging of subpictures [»suthIE5_1963]

Subtopic: type checking up

Quote: want separate checking of templates and their uses; if check the template and its uses against the template's parameter concepts, then instantiations should type check [»dosrG1_2006]

Subtopic: dynamic binding -- transcend representation up

Quote: dynamically bound messages allow methods to transcend the representation of the objects they manipulate [»ungaD10_1992]
Quote: generic programming decomposes software into components with minimal assumptions; allows reuse without modification, like successful libraries [»dehnJC4_1998]
Quote: a library should be flexible, allow polymorphic classes, efficient, and extensible without invalidating existing programs [»fricA4_2000]
Quote: polymorphism allows overlapping value sets which cover the universal value set

Subtopic: generic type up

Quote: how to add first-class generic types to Java or C#; mixins fully type checked, unlike templates [»alleE10_2003]
Quote: define generic, abstract data types with type parameters and hidden, representation types [»harmDE5_1991]
Quote: a param-type is a set of possible assignments to parameterized modes; e.g., all arrays of varying element types and bounds [»parnDL3_1976]

Subtopic: object-oriented up

Quote: object orientation is encapsulation + abstraction + polymorphism; groups object state and operations with information hiding [»nicoJR6_1993]
Quote: object-orientation overcomes the complexity of polymorphism in extensible languages [»ingaDH9_1986]

Subtopic: polymorphic procedures -- data-independent up

Quote: can have a library of data-independent procedures by postponing some declarations until compile-time [»hollGH12_1971]
Quote: syntax for the body of a polymorphic procedure is the same as for a nonpolymorphic procedure
Quote: if can prove a program correct according to its specifications, can then replace spec-types with other variables of the same type, but different modes
Quote: in Russell, polymorphic procedures can be recursive or procedure arguments [»demeA_1978]
Quote: use a polymorphic procedure to manipulate an object without accessing it, e.g., for sorting [»demeA_1978]
Quote: the apply_twice function modifier is polymorphic because it is independent of the operands type [»morrJH_1974]
Quote: Oberon has polymorphic operations

Subtopic: parametric polymorphism up

Quote: parametric polymorphism is better than dynamic approaches; errors caught at compile time; invariants expressed in types; fewer conversions, avoids run-time type checks [»kennA6_2001]
Quote: use just-in-time type specialization for generics; code generated as needed for parameterized classes; shared code and representations, no boxing, efficient runtime types [»kennA6_2001]
Quote: use SAME to indicate derived types in method signatures [»fricA4_2000]
Quote: parametric polymorphism by new code and data for each instantiation [C++], or one data representation with polymorphic code using pointer types, boxing, or tagged representations [»kennA6_2001]
Quote: CLR generics identify compatible parameterizations; i.e., reference types, struct types compatible if same layout re garbage collection; otherwise unshared code [»kennA6_2001]
Quote: use static type rules and lazy dictionary creation for parametric polymorphism; checked once instead of every instantiation [»kennA6_2001]
Quote: polymorphic Stack is faster than Stack of Object due to boxing of primitive values [»kennA6_2001]
Quote: Kleisli and its self-describing data exchange use parametric polymorphism and type inference; from functional programming [»wongL9_2000]
Quote: a scheme is a parameterized type that yields procedures, functions, types, and a signature [»demeA3_1979]

Subtopic: inheritance polymorphism up

Quote: inclusion polymorphism--operations on a given type are applicable to all subtypes; via inheritance
Quote: polymorphism is useful because it allows the uniform manipulation of objects by methods of a common superclass [»winkJF8_1992]
Quote: inheritance allows for polymorphic variables to become attached at run-time [»meyeB9_1990]

Subtopic: control of inheritance up

Quote: a virtual CLR method may be final (no derivation), new (parent method accessible), abstract (no implementation); interface methods are virtual [»hamiJ2_2003]
Quote: CLR does not specify method overloading; compiler explicitly specifies whether a method is virtual, non-virtual, or new [»hamiJ2_2003]

Subtopic: dynamic binding by argument type, method dispatch up

Quote: binding of names should depend on the argument type; makes selectors and procedures generic [»gescCM6_1975, OK]
Quote: an operator can have a polymorphic type, i.e., a union of signatures with different operand types [»kiebRB9_1973]
Quote: generic selection of procedures by matching argument types with parameter types [»mitcJG_1977]
QuoteRef: cbb_1973 ;;3/4/74 all operations defined by their context eg + quite different for reals and in t
Quote: spec-types have different representations but the same set of operators; operators are generic [»parnDL3_1976]
Quote: dynamic selection of a procedure according to class of object [»palmJ5_1973, OK]
Quote: Simscript allows the same operation name applied to different entities [»simscrip_1971, OK]
Quote: define operations as a pattern with its data types and corresponding routine [»wegbB5_1974, OK]
Quote: Dylan selects the function that best matches the arguments' type signature; may happen at compile time [»grayDN5_1998]
Quote: a built-in operation uses the correct data type automatically [»coxBJ7_1983]

Subtopic: dependent name up

Quote: within a template, x*x is a dependent name that depends on the type parameter; * is an implicit parameter [»dosrG1_2006]

Subtopic: multiple polymorphic arguments up

Quote: in object-oriented programming, more than one variable may be polymorphic; requires case analysis and poor modularity [»ingaDH9_1986]
Quote: handle messages that are doubly polymorphic, by sending additional messages to the second argument [»ingaDH9_1986]
Quote: argument matching rules for C++: exact match, integral promotions, standard conversions, user-defined conversions, parameter ellipsis; must be unique at a level [»stroB_1991]

Subtopic: operator overloading up

Quote: for operator overloading, assignment, equality, subscripting, and function call are more important than addition and subtraction [»koenA12_1995]
Quote: C++ operator overloading can overload function calls, array indexing, pointer dereference, assignment and initialization. May define type conversions and restrict copies and deletions [»stroB_1991]
Quote: to prevent ambiguities, C++ operator overloading can not change precedence, change expression syntax, or define operator tokens [»stroB_1991]
Quote: calling an overloaded C++ operator is the same as an explicit call to the operator function
Quote: C# overrides must include the override keyword; supports versioning when a base class introduces a new method [»wiltS10_2000]

Subtopic: type named operators up

Quote: the name of a CLU operation is always 't$o' where 't' is a type name; avoids overloading and enhances program correctness and readability [»liskB_1996]
Quote: the name of an overloaded C++ operator is 'operator' followed by the operator, e.g., 'operator<<'. [»stroB_1991]

Subtopic: polymorphic fields up

Quote: polymorphic records and variants allow functions that depend on field names alone; implicit typing [»wongL9_2000]

Subtopic: exceptions up

Quote: exception-neutrality for generic components; exceptions thrown by type parameters are passed unchanged to the component's caller [»abraD4_1998]
Quote: C++ containers are exception-safe generic components; no cost for normal operation, exceptions for cost comparable to a function call [»abraD4_1998]

Subtopic: template up

Quote: C++ Standard Template Library is good example of generic programming; data containers for user types; allows composition; compile time conversion of abstract type to concrete structures [»dehnJC4_1998]

Subtopic: macros up

Quote: in IMP, almost all entities are expressions and the compiler determines classes; allows polymorphic macros

Subtopic: specialization up

Quote: use factorization to convert a non-polymorphic specialization hierarchy into a polymorphic hierarchy; lose extensibility due to missing methods [»fricA4_2000]
Quote: difficult to build specialization hierarchies; must offer all solutions; can generate hierarchies from short specifications [»fricA4_2000]

Subtopic: type test up

Quote: need to determine the actual type to use a derived class. Ensure a homogeneous set, use a type field, or use virtual functions [»stroB_1991]

Subtopic: avoids type tests up

Quote: a type field leads to two kinds of errors in large programs: failure to test the type field and missed cases in a switch [»stroB_1991]

Subtopic: costs of polymophism up

Quote: generic selection only if operation is defined for those operands; otherwise forces generic selection on all callers [»wileDS11_1973, OK]
Quote: use immutable classes to convert a non-polymorphic specialization hierarchy into a polymorphic hierarchy; quadratic cost [»fricA4_2000]

Subtopic: problems with polymorphism up

Quote: in paper solutions, entities have state and they respond to requests for action; but no use of inheritance or polymorphism; object-oriented is not natural
[»paneJF2_2001]

Related Topics up

Group: data type   (34 topics, 730 quotes)

Topic: abstract data type (64 items)
Topic: abstract functions (11 items)
Topic: automatic selection of algorithm for abstract data type (7 items)
Topic: data type as a set of operations (38 items)
Topic: data type as constructors, selectors, and predicates (20 items)
Topic: dynamic vs. static data type (24 items)
Topic: early vs. late binding (15 items)
Topic: function signature (21 items)
Topic: interface type (50 items)
Topic: language flexibility (34 items)
Topic: macros (22 items)
Topic: non-exclusive data type (16 items)
Topic: object-oriented methods (42 items)
Topic: object-oriented templates and containers (27 items)
Topic: scripting language (27 items)
Topic: type parameter (34 items)
Topic: union data type
(12 items)


Updated barberCB 12/05
Copyright © 2002-2008 by C. Bradford Barber. All rights reserved.
Thesa is a trademark of C. Bradford Barber.