0
$\begingroup$

I am confused how to properly think about classes of classes. Basically, you can have a dog "filo" which is an instance of the dog "class". But the dog class is itself not an instanceof of "animal", but a subclass of animal. So animal is also a class. But that's just it, animal is an instanceof a class. So we have two layers of "instanceof". But then I get confused about "well, what exactly a class is an instance of, and what that thing is an instanceof, etc.".

More specifically, you can have these sort of statements....

  • a dog filo is an instance of a dog
  • a dog is a subclass of an animal
  • a dog is not an instance of an animal
  • an animal is an instance of a class
  • a dog is an instance of a class
  • a class is an instance of an object
  • an object is an instance of a class

So it's cyclic.

object instanceof class instanceof object instanceof class ...

More clearly, it is like this:

  • a class is an instance of an object class
  • an object is an instance of a class which is an instance of an object class
  • an object class is an instance of a class

This is where I start to get confused. I am not sure if you need sort of an infinite series of types.

You can also say:

  • dog is instance of object

But it's confusing to say:

  • object is an instance of an object

You would instead say:

  • object is an instance of an object class

But then we are at "object class is instance of object class n + 1, etc." That seems to be the reason for the infinite types, and "This is how we avoid the "Type : Type" paradox.".

I am confused also because in most programming languages you will see a type hierarchy that is basically only two levels:

Animal < Object

An Animal class is an instance of an Object class, and then var animal = new Animal means animal is an instance of Animal. But the question is what we do with Object. I wonder what type Object is. If it is just type Object, as in:

Object < Object

But this seems like a contradiction or some circular reasoning that seems to not be quite right and I can't pinpoint it.

Wondering if one can explain what is a mathematically sound type hierarchy in this sense, if it is okay for it to be circular or if it must be an infinite series of some sort. By circular I mean:

Animal instanceof Class
Class instanceof Object
Object instanceof Class
Class instanceof Object
...

By infinite I mean something along the lines of:

Animal instanceof Class
Class instanceof Object
Object instanceof Object Class
Object Class instanceof Object2
Object2 instanceof Object2 Class
Object2 Class instanceof Object3
Object3 instanceof Object3 Class
...
Objectn-1 Class instanceof Objectn
Objectn instanceof Objectn Class

https://cstheory.stackexchange.com/questions/22734/why-an-infinite-type-hierarchy

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.