Re: [Python-ideas] add __contains__ into the "type" object

March 1, 2017
12:04 a.m.
TYPE is not a collection! But conceptually it is a SET, set of all its possible instances. quot: "Types and Programming Languages (2002)(Benjamin C. Pierce)" [page 92] Chapter 8 Typed Arithmetic Expressions "a term t has type T" (or "t belongs to T," or "t is an element of T") An object obj has a type T or obj is a type T <==> obj belongs to T So, "obj in T" is fine. e.g. "1 in int" means 1 is in the whole number set.
Note that TYPE is SET; What does that mean? I don't understand.
obj in T; But obj is **not** in T, since T is a type, not a container.
"is-a" tests are not the same as "in" tests. They are completely unrelated comparisons.
2940
Age (days ago)
2940
Last active (days ago)
0 comments
1 participants
participants (1)
-
语言破碎处