Search code examples
programming-languagestypeslanguage-design

What is a universal type?


I have heard the term "universal type" thrown around in the context of programming language type systems, does anybody know what this means? Is is something to do with objects like a String where two instances of "foo" are identical even though ("foo"=="foo") may be false?


Solution

  • A quick Wikipedia search turns up: 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." In other words, it's the "Object" class, which is (directly or indirectly) a superclass of every other class. As the page points out, C++ is unusual among OO languages since it doesn't have a universal type.