开发者

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 som开发者_运维技巧ething to do with objects like a String where two instances of "foo" are identical even though ("foo"=="foo") may be false?


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.


Russell's Paradox lurks in the wings. Just as you can break your mathematical system when you start getting into things like "the set of all sets", you can also break your type system if you are a little too blasé about a type of all types. Designing type systems requires a little bit of care.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜