Nominative type system

From Wikipedia, the free encyclopedia

In computer science nominative type system is a major class of type system, in which type compatibility and equivalence is determined by explicit declarations and/or the name of the types. Nominative systems are used to determine if types are equivalent, as well as if a type is a subtype of another. It contrasts with structural systems, where comparisons are based on the structure of the types in question and do not require explicit declarations.

Nominal typing means that two variables have compatible types only if they appear in either the same declaration or in declarations that use same type name. Note that many languages provide a way of type aliasing; or declaring multiple names of the same type. The C/C++ typedef feature is an example of this capability. C# and Java are all examples of languages which use name type compatibility.

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 to be subtypes, are not considered to be subtypes.

C, C++, C# and Java all primarily use both nominal typing and nominal subtyping. C and C++ permit limited structural subtyping for anonymous types (two anonymous types are considered equivalent if they have the same structure, even if the types are "described" in different parts of the code).

Some nominally-subtyped languages, such as Java and C#, allow classes to be declared final (or sealed in Microsoft's terminology), indicating that no further subtyping is permitted.

Nominal typing is useful at preventing accidental type equivalence, and is considered to have better type-safety than structural typing. The cost is a reduced flexibility, as, for example, nominal typing does not allow new super-types to be created without modification of the existing subtypes.

Advanced Search
Included Web Search Engines


Safe Search

close

Top Matching Results

Occasionally Search.com will highlight specialized results that are based on the context of your query. Examples of specialized results include specific links to news, images, or video.

Top Matching Results may highlight information from other Search.com pages, content from the CNET Network of sites, or third party content. The listings are based purely on relevance. Search.com does not receive payment for listings in this section but our partners that provide this data may get paid for listing these products.

Sponsored Links

This section contains paid listings which have been purchased by companies that want to have their sites appear for specific search terms and related content. These listings are administered, sorted and maintained by a third party and are not endorsed by Search.com.

Search Results

Search.com sends your search query to several search engines at one time and integrates the results into one list which has been sorted by relevance using Search.com's proprietary algorithm. You can customize the list of search engines included in your metasearch from the preferences.

The search engines that are used in your metasearch may allow companies to pay to have their Web sites included within the results. To view the Paid Inclusion policy for a specific search engine, please visit their Web site. Search.com does not accept payment or share revenue with any search engine partner for listings in this section.