Top type

Top type

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.

upport in programming languages

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

Most object oriented programming languages include a universal base class:
* In Glib, the base class is Gobject.
* Object in Smalltalk, Java, JavaScript, Ruby, and some others. In Java, it is frequently prefixed written with a package designation, as Javadoc:SE|package=java. _ja. Object. Note also that Object is not a supertype of the primitive types in Java.
* [http://msdn.microsoft.com/en-us/library/system.object.aspx System.Object] in C#, Visual Basic .NET and other .NET Framework languages
* object in Python since the [http://www.python.org/download/releases/2.2.3/descrintro/ type/class unification] in Version 2.2.
* GENERAL in Eiffel.
* t in Common Lisp and many other Lisp dialects.
* Object in Objective-C. In OpenStep and Cocoa, which are the most popular frameworks based on the language, it is NSObject.
* UNIVERSAL in Perl 5.
* Variant in Visual Basic up to version 6

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

* [http://www.c2.com/cgi/wiki?TopType c2.com: Top type]


Wikimedia Foundation. 2010.

Игры ⚽ Поможем сделать НИР

Look at other dictionaries:

  • Type 72 non-metallic anti-tank mine — Type 72 Non Metallic is a Chinese circular, plastic bodied landmine which is designed to damage or destroy a vehicle by blast effect. Mechanism The mine has a slightly domed pressure plate which is made of flexible plastic with a raised 6 spoke… …   Wikipedia

  • Top (disambiguation) — A Top is a spinning toy. Top may refer to:* Top (BDSM), a person who assumes the dominant role in a BDSM relationship * Top (comics), a supervillain character from the DC Comics universe * Top (clothing), clothing that is designed to be worn over …   Wikipedia

  • Top Gear — Логотип передачи Жанр автомобильное телешоу …   Википедия

  • Top-bar hive — Top bar hives are a style of beehive used for beekeeping. They are especially useful in areas where resources are limited, but are also increasingly popular among hobby beekeepers in industrialized nations. This article is primarily concerned… …   Wikipedia

  • Top Gear challenges — are a segment of the Top Gear television programme where the presenters are challenged by the producers, or by each other, to prove or do various things related to automobiles. Contents 1 Novelty/stunt challenges 2 Challenge reviews 3 How hard… …   Wikipedia

  • Top Gear Segments — Top Gear has featured a number of recurring segments on the show. The most popular are listed here. These elements make up the basic structure of the show.RacesEpic racesThere have been six epic races on Top Gear, involving a car racing another… …   Wikipedia

  • Top Fuel — Racing is a class of drag racing in which the cars are run on a maximum of 90% nitromethane and about 10% methanol (also known as racing alcohol), instead of gasoline. The cars are purpose built race cars, with a layout superficially resembling… …   Wikipedia

  • Type-in traffic — is a term describing visitors landing at a web site by entering a keyword or phrase (with no spaces or a hyphen in place of a space) in the web browser s address bar (and adding .com or in a mobile browser address bar and adding .mobi or any… …   Wikipedia

  • Type — Type, n. [F. type; cf. It. tipo, from L. typus a figure, image, a form, type, character, Gr. ? the mark of a blow, impression, form of character, model, from the root of ? to beat, strike; cf. Skr. tup to hurt.] [1913 Webster] 1. The mark or… …   The Collaborative International Dictionary of English

  • Type founder — Type Type, n. [F. type; cf. It. tipo, from L. typus a figure, image, a form, type, character, Gr. ? the mark of a blow, impression, form of character, model, from the root of ? to beat, strike; cf. Skr. tup to hurt.] [1913 Webster] 1. The mark or …   The Collaborative International Dictionary of English

Share the article and excerpts

Direct link
Do a right-click on the link above
and select “Copy Link”