In a similar fashion, nominal subtyping means that one type is a subtype of another if and only if it is explicitly declared to be so in its definition. Nominally-typed languages typically enforce the requirement that declared subtypes be structurally compatible (though Eiffel allows non-compatible subtypes to be declared). However, subtypes which are structurally compatible "by accident", but not declared as subtypes, are not considered to be subtypes.
C, C++, C# and Java all primarily use both nominal typing and nominal subtyping.
In 2012, AbdelGawad proved that, in contrast to structurally-typed languages, in nominally-typed OO languages class/interface inheritance and class/interface subtyping do completely agree (ie, that inheritance is subtyping), due to the association of class names with class contracts.
Some nominally-subtyped languages, such as Java and C#, allow classes to be declared final (or sealed in C# terminology), indicating that no further subtyping is permitted.
Read more about this topic: Nominative Type System
Famous quotes containing the word nominal:
“Discourage litigation. Persuade your neighbors to compromise whenever you can. Point out to them how the nominal winner is often a real loserin fees, expenses, and waste of time. As a peacemaker the lawyer has a superior opportunity of being a good man. There will still be business enough.”
—Abraham Lincoln (18091865)