Terminology of types / typing [was: PEP 560 (second post)]

Here are some thoughts––maybe even a proposal––for type-related terminology, because clear terminology makes discussion and reasoning easier, and helps avoid errors. (And related to the PEP 560 thread, the question of what should go into class attributes like __bases__). Terminology regarding types is confusing enough, and of all the terminology I've seen, I like these most: * concrete type: something that concretely implements data storage or functionality. Usually this is a normal class. * abstract type: an assumption or set of assumptions made about an instance. While both kinds can (and probably should) have a corresponding runtime representation, there's not that much that we can currently assume about the second kind––abstract types. They could be almost anything. Anyway, regarding PEP 560, in my speculated naming, the __bases__ attribute of a class would contain both concrete and abstract bases. Those with any concrete method implementations should go in the mro. But then there's the problem that "abstract base classes" may contain both concrete and abstract methods. What do we call such a "type"? Maybe we have both "concrete" and "strictly concrete" types. Perhaps we also have both "abstract" and "strictly abstract" types. An ABC with some concrete default implementations might then be both a concrete type and an abstract type. Note that in the above bullet point "definition" of concrete type, I intentionally left out the requirement that the type can be instantiated. The other two bullet points are: * strictly concrete type: a concrete type that is not abstract––it concretely implements everything that it represents / describes. This is almost always a normal class, so it might be also known as "class". * strictly abstract type: an abstract type that is not concrete––it does not implement any functionality or storage. There might be a way to improve terminology from this, but I feel that what I sketched here is usable but still not very ambiguous. ––Koos -- + Koos Zevenhoven + http://twitter.com/k7hoven +

On Wed, Nov 15, 2017 at 1:41 PM, Koos Zevenhoven <k7hoven@gmail.com> wrote: [..]
Let me rephrase that last sentence: I think this terminology is more clear. And here's some additional clarification: I expect that the possibility of a type being both concrete and abstract may sound strange. In some ways it is indeed strange, but this overlap of concepts definitely exists already, we just need to categorize and define the concepts clearly, but without introducing too many concepts whose relations to each other are messy. This might also seem strange if you are not used to how "strict" is often used in mathematics and related sciences. Essentially, it's synonymous to "proper". For example, "strict subset" and "proper subset" of a set both refer to a subset that is not the set itself. Any set is both a superset and subset of itself (in non-strict terms). Also "pure" might sometimes refer to something similar. So in some sense it means excluding the "gray area". Often that "gray area" is kept part of the non-strict/improper concept for convenience. ––Koos -- + Koos Zevenhoven + http://twitter.com/k7hoven +

On Wed, Nov 15, 2017 at 8:41 PM, Ivan Levkivskyi <levkivskyi@gmail.com> wrote:
Yeah, well I was trying to wrap my head around this runtime vs static thing for quite some time, and it never felt quite right. I'm not sure that runtime vs static is a useful distinction at all. In the current situation of typing in python, I think it misses the point slightly. One might also say that, at static-analysis time, all types are static--including normal classes. But those correspond to concepts at runtime--abstract or concrete. -- Koos
-- + Koos Zevenhoven + http://twitter.com/k7hoven +

On Wed, Nov 15, 2017 at 1:41 PM, Koos Zevenhoven <k7hoven@gmail.com> wrote: [..]
Let me rephrase that last sentence: I think this terminology is more clear. And here's some additional clarification: I expect that the possibility of a type being both concrete and abstract may sound strange. In some ways it is indeed strange, but this overlap of concepts definitely exists already, we just need to categorize and define the concepts clearly, but without introducing too many concepts whose relations to each other are messy. This might also seem strange if you are not used to how "strict" is often used in mathematics and related sciences. Essentially, it's synonymous to "proper". For example, "strict subset" and "proper subset" of a set both refer to a subset that is not the set itself. Any set is both a superset and subset of itself (in non-strict terms). Also "pure" might sometimes refer to something similar. So in some sense it means excluding the "gray area". Often that "gray area" is kept part of the non-strict/improper concept for convenience. ––Koos -- + Koos Zevenhoven + http://twitter.com/k7hoven +

On Wed, Nov 15, 2017 at 8:41 PM, Ivan Levkivskyi <levkivskyi@gmail.com> wrote:
Yeah, well I was trying to wrap my head around this runtime vs static thing for quite some time, and it never felt quite right. I'm not sure that runtime vs static is a useful distinction at all. In the current situation of typing in python, I think it misses the point slightly. One might also say that, at static-analysis time, all types are static--including normal classes. But those correspond to concepts at runtime--abstract or concrete. -- Koos
-- + Koos Zevenhoven + http://twitter.com/k7hoven +
participants (2)
-
Ivan Levkivskyi
-
Koos Zevenhoven