[Python-ideas] add __contains__ into the "type" object
语言破碎处
mlet_it_bew at 126.com
Tue Feb 28 19:04:40 EST 2017
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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20170301/27d33aa8/attachment.html>
More information about the Python-ideas
mailing list