Well, it depends on the language you use; in pure OO languages, where everything is an object (e.g. Smalltalk ), classes are no exception and are objects. In other languages where classes are not considered first-class citizens, they are simply special language constructs or primitive types. From now on, I will use Smalltalk as the target language because of its support for reflection and uniform style.
Access to class methods is carried out only by the name of the class name .method? (inner work). Is it the same as object.method?
Because classes are objects, they are in turn instances of the class (a metaclass ). Thus, sending a message to a class simply sends a message to an object whose role should represent class behavior. There is a lot of literature, you can look here here and here for acquaintance.
And if the class is the same as the object (belongs to the class of the object that is the super class of every thing in OO) and we create it (we will make the object out of this), can we make an instance of the class different from the Object class.
I'm not sure that I am following you here, but just to clarify, it does not always happen that Object is the superclass of all classes. The fact is that if you start to monitor the relationships between classes and metaclasses, you can achieve a kind of infinite loop. Different languages work differently and, for example, in VisualWorks Smalltalk, Object is a subclass of nil . The fact is that nil also an object (remember that everything is an object) and actually represents "nothing." As you would expect, nil is an instance of the class ( UndefinedObject ), and also implements some of the class's protocols. As a result, it can be used to represent the form of a class where nothing is inherited :).
Finally, I don’t know if this answers your question, but yes, you can do many cool things with full reflective ability, for example, create new classes on the fly or modify existing ones. I will leave you here some documents that may seem interesting on this topic:
Andrés fortier
source share