Dictionary
Thesaurus
Reference
Translate
Web
Related Searches
on Ask.com
Top type
1 reference results for: Top type
Wikipedia
The top type in type theory, commonly abbreviated as top or by the down tack symbol (⊤) is the universal type--that type which contains every possible object in the type system of interest. The top type is sometimes called the universal supertype as all other types in any given type system are subtypes of top. It is in contrast with the bottom type, or the universal subtype, which is the type containing no members at all.

Support in programming languages

Several typed programming languages provide explicit support for the top type.

Most object oriented programming languages include a universal base class:

C++ is unusual among OO languages in that it does not have a universal supertype. The "pointer to void" type can accept a pointer to any object, even though the void type itself is not the universal type but the unit type.

Non-OO languages usually do not have a universal supertype (or support subtype polymorphism at all). Common Lisp is an exception in that its built-in types form a type hierarchy even when its object system CLOS is not used.

In most programming languages, the top type is an abstract type--it contains no elements which are not elements of some (declared) subtype. Java is an exception: the phrase new Object() is perfectly legal Java.

The top type is used as a generic type, particularly in languages without parametric polymorphism. For example, prior to the introduction of generics in Java 5, collection classes in the Java library (excluding Java arrays) held references of type Object; in this way any non-intrinsic type could be inserted into a collection. The top type is also frequently used to hold objects of unknown type.

The top type may also be seen as the implied type of non-statically typed languages. Languages with runtime typing often provide downcasting (or type refinement) to allow the programmer to discover a more specific type for an object at run-time. Note that downcasting from void * in C++ cannot be done in a "safe" manner, where failed downcasts are detected by the language runtime.

References

External links

Share This:Share This: digg.comShare This: ma.gnolia.comShare This: www.stumbleupon.comShare This: del.icio.usShare This: FacebookShare This: favorites.live.comShare This: www.technorati.comShare This: furl.netShare This: myweb2.search.yahoo.comShare This: www.google.com