词条 | Top type | ||||||||||||||||||||||||||||
释义 |
The top type in the type theory of mathematics, logic, and computer science, commonly abbreviated as top or by the down tack symbol (⊤), is the universal type, sometimes called the universal supertype as all other types in any given type system are subtypes of top. In most cases it is the type which contains every possible object in the type system of interest. It is in contrast with the bottom type, or the universal subtype, which every other type is supertype of and in most cases it is the type that contains no members at all. Support in programming languagesSeveral typed programming languages provide explicit support for the top type. In statically-typed languages, there are two different, often confused, concepts when discussing the top type.
The first concept often implies the second, i.e., if a universal base class exists, then a variable that can point to an object of this class can also point to an object of any class. However, several languages have types in the second regard above (e.g., In dynamically-typed languages, the second concept does not exist (any value can be assigned to any variable anyway), so only the first (class hierarchy) is discussed. This article tries to stay with the first concept when discussing top types, but also mention the second concept in languages where it is significant.
The following object-oriented languages have no universal base class:
Other languagesLanguages that are not object-oriented usually have no universal supertype, or subtype polymorphism support. While Haskell purposefully lacks subtyping, it has several other forms of polymorphism including parametric polymorphism. The most generic type class parameter is The top type is used as a generic type, more so in languages without parametric polymorphism. For example, before introduing generics in Java 5, collection classes in the Java library (excluding Java arrays) held references of type In languages with a structural type system, the top type is the empty structure. For example, objects in OCaml are structurally typed; the empty object type (the type of objects with no methods), The top type may also be seen as the implied type of non-statically typed languages. Languages with run time typing often provide downcasting (or type refinement) to allow discovering a more specific type for an object at run time. In C++, downcasting from In logicThe notion of top is also found in propositional calculus, corresponding to a formula which is true in every possible interpretation. It has a similar meaning in predicate calculus. In description logic, top is used to refer to the set of all concepts. This is intuitively like the use of the top type in programming languages. For example, in the Web Ontology Language (OWL), which supports various description logics, top corresponds to the class See also
Notes1. ^{{cite web |url=http://www.ruby-doc.org/core-1.9.2/BasicObject.html |title=Class: BasicObject (Ruby 1.9.2) |accessdate=April 7, 2014}} 2. ^System.Object 3. ^[https://www.python.org/download/releases/2.2.3/descrintro/ Python type/class unification] 4. ^{{cite web |url=http://www.scala-lang.org/docu/files/ScalaOverview.pdf |title=An Overview of the Scala Programming Language |year=2006 |accessdate=April 7, 2014}} 5. ^{{cite web |url=http://www.ecma-international.org/publications/files/ECMA-ST/ECMA-367.pdf |title=Standard ECMA-367. Eiffel: Analysis, Design and Programming Language |year=2006 |accessdate=March 10, 2016}} References
External links
2 : Data types|Type theory |
||||||||||||||||||||||||||||
随便看 |
|
开放百科全书收录14589846条英语、德语、日语等多语种百科知识,基本涵盖了大多数领域的百科知识,是一部内容自由、开放的电子版国际百科全书。