- subprograms (generic function);
- types and classes of (generic types);
- objects (generic object);
- compilation units (generic package).
For example, a generic function describes a set of functions, a generic type describes a set of types, etc.
Such generic sets are called generics or templates. Being a set, the generics itself is not yet a subject of the programming language. It must first be constrained to an element of the set in order to identify a concrete subprogram, type, object, package, etc. So the language of generics constitutes a meta language relative to the underlying programming language (the object language).
The process of constraining a generic is called instantiation. The result of instantiation is a generic instance. Instantiation can be
Instantiation constrains the generic set by defining generic formal parameters. What can serve as a generic formal parameter depends on the language. In the most general case it can be a subprogram, type, object, instance of another generic.
Partial definition or constraining of some of generic formal parameters of a generics is called generic specialization. Specialization produces another generic rather than an instance of a generic.
Like any other programming language, the meta language of generics can be typed. In a typed language of generics, substitution of an actual generic parameter is checked upon instantiation against the formal generic type. The choice does not necessarily depend on the object language. For example, C++ is typed, but its language of generics is not.
Generics are sometimes said to be parametric or else static polymorphic. The effect of generic programming in object-oriented programming is achieved by means dynamic polymorphism. In this case generic programming is narrowed to the programming in terms of sets of types (i.e. classes), rather than arbitrary sets of language entities.
Historically generic programming first appeared in the form of macro languages and preprocessors.
This category has the following 25 subcategories, out of 25 total.
- D (3 C, 985 P)
- Ecstasy (46 P)
- FormulaOne (1 P)
- Java (3 C, 1,188 P)
- Morfa (9 P)
- Scala (23 C, 901 P)
- Sidef (1 C, 1,003 P)
- SkookumScript (1 C, 6 P)
- SQL PL (3 C, 40 P)
- TypeScript (1 C, 46 P)
- Visual Prolog (7 P)