Описание тега structural-typing
Structural typing is the ability of a type system to identify a type based on what data it contains, rather than how a type is named.
Most programming languages identify types based on their names. For example, in a nominally typed language the types A
and B
in the code below are different, because they are named differently.
struct A { int a; float b; }
struct B { int a; float b; }
In a structurally typed programming language (which includes OCaml, Haskell, and Scala), the types A
and B
are the same, because they both contain an int a
and a float b
.
The Wikipedia page contains a more detailed introduction, and WikiWikiWeb has discussions about the differences between Nominative and Structural typing.
Generally, anything about structural typing should be acceptable on Stackru, as long as it does not fit better on Programmers or CSTheory.