SubtypingIn programming language theory, subtyping (also subtype polymorphism or inclusion polymorphism) is a form of type polymorphism in which a subtype is a datatype that is related to another datatype (the supertype) by some notion of substitutability, meaning that program elements, typically subroutines or functions, written to operate on elements of the supertype can also operate on elements of the subtype. If S is a subtype of T, the subtyping relation (written as S
Polymorphisme (informatique)En informatique et en théorie des types, le polymorphisme, du grec ancien polús (plusieurs) et morphê (forme), est le concept consistant à fournir une interface unique à des entités pouvant avoir différents types. Par exemple, des opérations telles que la multiplication peuvent ainsi être étendues à des scalaires aux vecteurs ou aux matrices, l'addition, des scalaires aux fonctions ou aux chaînes de caractères, etc.
Type systemIn computer programming, a type system is a logical system comprising a set of rules that assigns a property called a type (for example, integer, floating point, string) to every "term" (a word, phrase, or other set of symbols). Usually the terms are various constructs of a computer program, such as variables, expressions, functions, or modules. A type system dictates the operations that can be performed on a term. For variables, the type system determines the allowed values of that term.
Système nominatif de typesUn système nominatif de types est une classe majeure de système de types en programmation informatique. C'est avec lui qu'on détermine la compatibilité et l'équivalence de types par la déclaration explicite et/ou le nommage des types. On utilise les systèmes nominatifs pour déterminer si des types sont équivalents ou pour savoir si un type est un sous-type d'un autre. Ce système est en contraste avec le système structurel, où les comparaisons sont fondées sur la structure des types en question et donc ces types ne nécessitent pas de déclarations explicites.
Principe de substitution de Liskovvignette|Barbara Liskov en 2010 Le principe de substitution de Liskov (LSP) est, en programmation orientée objet, une définition particulière de la notion de sous-type. Il a été formulé par Barbara Liskov et Jeannette Wing dans un article intitulé Family Values: A Behavioral Notion of Subtyping : Liskov et Wing en ont proposé la formulation condensée suivante : Si est une propriété démontrable pour tout objet de type , alors est vraie pour tout objet de type tel que est un sous-type de .
Parametric polymorphismIn programming languages and type theory, parametric polymorphism allows a single piece of code to be given a "generic" type, using variables in place of actual types, and then instantiated with particular types as needed. Parametrically polymorphic functions and data types are sometimes called generic functions and generic datatypes, respectively, and they form the basis of generic programming. Parametric polymorphism may be contrasted with ad hoc polymorphism.
Is-aAn is-a relationship is when one type of object 'is a' instance of another type of object. For example, a cat 'is a' animal, but not vice versa. All cats are animals, but not all animals are cats. The concept becomes important in object oriented programing, where 'is a' relationships are often used as a way to structure code - behaviour that are is relevant to all animals is defined on an animal class, whereas behaviour that is relevant only for cats is defined in a cat class.
Ad hoc polymorphismIn programming languages, ad hoc polymorphism is a kind of polymorphism in which polymorphic functions can be applied to arguments of different types, because a polymorphic function can denote a number of distinct and potentially heterogeneous implementations depending on the type of argument(s) to which it is applied. When applied to object-oriented or procedural concepts, it is also known as function overloading or operator overloading.
Théorie des typesEn mathématiques, logique et informatique, une théorie des types est une classe de systèmes formels, dont certains peuvent servir d'alternatives à la théorie des ensembles comme fondation des mathématiques. Ils ont été historiquement introduits pour résoudre le paradoxe d'un axiome de compréhension non restreint. En théorie des types, il existe des types de base et des constructeurs (comme celui des fonctions ou encore celui du produit cartésien) qui permettent de créer de nouveaux types à partir de types préexistant.
Type classIn computer science, a type class is a type system construct that supports ad hoc polymorphism. This is achieved by adding constraints to type variables in parametrically polymorphic types. Such a constraint typically involves a type class T and a type variable a, and means that a can only be instantiated to a type whose members support the overloaded operations associated with T.
Définition d'opérateurLa définition d'opérateur est une fonctionnalité offerte par certains langages de programmation qui permet d'utiliser des opérateurs (comme +, = ou ==) comme des fonctions ou des méthodes en les définissant pour de nouveaux types de données. Les opérateurs ne sont pas nécessairement des symboles. Parfois, la définition de nouveaux opérateurs est autorisée. Il s'agit généralement de sucre syntaxique, et peut facilement être émulé par des appels de fonction ou de méthode : avec définition d'opérateurs : a + b * c ; sans définition d'opérateurs : somme (a, produit (b, c)).
Substructural type systemSubstructural type systems are a family of type systems analogous to substructural logics where one or more of the structural rules are absent or only allowed under controlled circumstances. Such systems are useful for constraining access to system resources such as , locks, and memory by keeping track of changes of state that occur and preventing invalid states. Several type systems have emerged by discarding some of the structural rules of exchange, weakening, and contraction: Ordered type systems (discard exchange, weakening and contraction): Every variable is used exactly once in the order it was introduced.
Top typeIn mathematical logic and computer science, some type theories and type systems include a top type that is commonly denoted with top or the symbol ⊤. The top type is sometimes called also universal type, or universal supertype as all other types in the type system of interest are subtypes of it, and in most cases, it contains every possible object of the type system. It is in contrast with the bottom type, or the universal subtype, which every other type is supertype of and it is often that the type contains no members at all.
Kind (type theory)In the area of mathematical logic and computer science known as type theory, a kind is the type of a type constructor or, less commonly, the type of a higher-order type operator. A kind system is essentially a simply typed lambda calculus "one level up", endowed with a primitive type, denoted and called "type", which is the kind of any data type which does not need any type parameters. A kind is sometimes confusingly described as the "type of a (data) type", but it is actually more of an arity specifier.
C++C++ est un langage de programmation compilé permettant la programmation sous de multiples paradigmes, dont la programmation procédurale, la programmation orientée objet et la programmation générique. Ses bonnes performances, et sa compatibilité avec le C en font un des langages de programmation les plus utilisés dans les applications où la performance est critique. Créé initialement par Bjarne Stroustrup dans les années 1980, le langage C++ est aujourd'hui normalisé par l'ISO.
Sûreté du typageLa sûreté du typage est un principe permettant d'améliorer la qualité de la programmation. Dans les langages à typage statique, l'un des objectifs est d'intercepter les erreurs de type de données lors de la compilation. Un type peut être vu comme un ensemble de valeurs et un ensemble d'opérateurs. La programmation objet a introduit les notions d'objets, messages, classes, héritage. Il est tentant de faire coller les classes à des types.
Array (data type)In computer science, array is a data type that represents a collection of elements (values or variables), each selected by one or more indices (identifying keys) that can be computed at run time during program execution. Such a collection is usually called an array variable or array value. By analogy with the mathematical concepts vector and matrix, array types with one and two indices are often called vector type and matrix type, respectively. More generally, a multidimensional array type can be called a tensor type, by analogy with the physical concept, tensor.
Covariance and contravariance (computer science)Many programming language type systems support subtyping. For instance, if the type is a subtype of , then an expression of type should be substitutable wherever an expression of type is used. Variance is how subtyping between more complex types relates to subtyping between their components. For example, how should a list of s relate to a list of s? Or how should a function that returns relate to a function that returns ? Depending on the variance of the type constructor, the subtyping relation of the simple types may be either preserved, reversed, or ignored for the respective complex types.
Polymorphisme génétiqueLe polymorphisme génétique (du grec « poly » plusieurs et « morphê » forme) est la coexistence de plusieurs allèles pour un gène ou locus donné, dans une population animale, végétale, fongique, bactérienne. Il explique qu'une espèce présente des individus aux caractères phénotypiques différents (appelés morphotypes) au sein d'une même population. C'est un des éléments, intraspécifique, de la diversité génétique qui est considéré comme facilitant l'adaptation des populations à leur environnement plus ou moins changeant.
Inférence de typesL'inférence de types est un mécanisme qui permet à un compilateur ou un interpréteur de rechercher automatiquement les types associés à des expressions, sans qu'ils soient indiqués explicitement dans le code source. Il s'agit pour le compilateur ou l'interpréteur de trouver le type le plus général que puisse prendre l'expression. Les avantages à disposer de ce mécanisme sont multiples : le code source est plus aéré, le développeur n'a pas à se soucier de retenir les noms de types, l'interpréteur fournit un moyen au développeur de vérifier (en partie) le code qu'il a écrit et le programme est peu modifié en cas de changement de structure de données.