A structural type system (or property-based type system) is a major class of type system, in which type compatibility and equivalence are determined by the type's structure, and not through explicit declarations. Structural systems are used to determine if types are equivalent, as well as if a type is a subtype of another.
| Property | Value |
| dbpprop:abstract
|
- A structural type system (or property-based type system) is a major class of type system, in which type compatibility and equivalence are determined by the type's structure, and not through explicit declarations. Structural systems are used to determine if types are equivalent, as well as if a type is a subtype of another. It contrasts with nominative systems, where comparisons are based on explicit declarations or the names of the types, and duck typing, in which only the part of the structure accessed at runtime is checked for compatibility. In structural typing, two objects or terms are considered to have compatible types if the types have identical structure. Depending on the semantics of the language, this generally means that for each feature within a type, there must be a corresponding and identical feature in the other type. Some languages may differ on the details (such as whether the features must match in name). ML, Whiteoak and Objective Caml are examples of structurally-typed languages. HaXe uses structural typing, although classes are not structurally subtyped. In languages which support subtype polymorphism, a similar dichotomy can be formed based on how the subtype relationship is defined. One type is a subtype of another if and only if it contains all the features of the base type (or subtypes thereof); the subtype may contain additional features (such as members not present in the base type, or stronger invariants). Structural subtyping is arguably more flexible than nominative subtyping, as it permits the creation of ad hoc types and interfaces; in particular, it permits creation of a type which is a supertype of an existing type T, without modifying the definition of T. However this may not be desirable where the programmer wishes to create closed abstractions. A pitfall of structural typing versus nominative typing is that two separately defined types intended for different purposes, each consisting of a pair of numbers, could be considered the same type by the type system, simply because they happen to have identical structure. One way this can be avoided is by creating one algebraic data type for one use of the pair and another algebraic data type for the other use.
- En Programmation informatique, un système structurel de types est une classe majeure de système de types, dans laquelle la compatibilité et l'équivalence de type est déterminée par la structure du type et non par des déclarations explicites. On utilise les systèmes structuraux pour déterminer si les types sont équivalents, ou si un type est un sous-type d'un autre. Ce système est en opposition avec les systèmes nominatifs où les comparaisons sont basées sur des déclarations explicites ou sur le nom des types. Avec le typage structurel deux objets ou termes sont considérés comme ayant des types compatibles si leurs types ont une structure identique. Selon la sémantique du langage, cela signifie généralement que pour chaque fonctionnalité dans un type il doit y voir une fonctionnalité correspondante dans l'autre type. Les détails changent selon les langages. Ainsi sur le fait que deux fonctionnalités doivent avoir le même nom pour être considérées identiques. Haskell et ML sont deux langages au typage structurel. Haxe est un langage au typage structurel bien que ses classes ne soient pas structurellement sous-typées. Dans les langages qui supportent le sous-typage polymorphique, on peut former une dichotomie similaire pour définir une relation de sous-type. Un type est un sous-type d'un autre si et seulement il contient toutes les fonctionnalités du type de base ou de l'un de ses sous-types. Le sous-type peut contenir des fonctionnalités additionnelles telles que des membres non présents dans le type de base ou des invariants plus forts. Le sous-typage structurel est plus flexible que le sous-typage nominal, car il permet la création de types et d'interfaces ad hoc. Il permet en particulier la création d'un type qui est un super-type d'un type existant T sans modifier la définition de T. Mais cela peut ne pas être désirable quand un programmeur veut créer des abstractions fermées. Le piège du typage structurel comparé au typage nominal est que si deux types définis séparément pour des buts différents, chacun consistant en une paire de nombres sont considéres du même type par le système de type, simplement parce qu'ils ont une structure identique, Une manière d'éviter cela est de créer un type algébrique pour un type de paire et un autre pour l'autre type de paire.
|
| dbpprop:hasPhotoCollection
| |
| dbpprop:reference
| |
| rdfs:comment
|
- A structural type system (or property-based type system) is a major class of type system, in which type compatibility and equivalence are determined by the type's structure, and not through explicit declarations. Structural systems are used to determine if types are equivalent, as well as if a type is a subtype of another.
- En Programmation informatique, un système structurel de types est une classe majeure de système de types, dans laquelle la compatibilité et l'équivalence de type est déterminée par la structure du type et non par des déclarations explicites. On utilise les systèmes structuraux pour déterminer si les types sont équivalents, ou si un type est un sous-type d'un autre.
|
| rdfs:label
|
- Structural type system
- Système structural de types
|
| owl:sameAs
| |
| skos:subject
| |
| foaf:page
| |
| is dbpprop:redirect
of | |
| is dbpprop:typing
of | |