Erhalten Sie Zugang zu diesem und mehr als 300000 Büchern ab EUR 5,99 monatlich.
What is the class Object? What is the class Class? Why the class Object is an instance of the class Class? If you ever ask yourself such questions, this book is for you. After explaining the impact of representing classes as objects, you will develop step by step a minimal reflective kernel. In this book you will learn: - object instantiation, allocation, and initialization, - classes as objects, - description of classes, - creation of classes, - method lookup and error handling, - examples of metaclasses, - bootstrap of a reflective system. The content of this book has been used to teach reflective architectures for more than 15 years.
Sie lesen das E-Book in den Legimi-Apps auf:
Seitenzahl: 79
Veröffentlichungsjahr: 2024
Das E-Book (TTS) können Sie hören im Abo „Legimi Premium” in Legimi-Apps auf:
Building a minimal reflective kernel
S. Ducasse
November 9, 2024
1 A minimal reflective class-based kernel
1.1 ObjVlisp inspiration
1.2 ObjVLisp’s six postulates
1.3 Kernel overview
1.4 Conclusion
2 Diving into the kernel
2.1 Instances
2.2 Understanding metaclasses
2.3 Instance structure
2.4 About behavior
2.5 Class as an object
2.6 Sending a message
2.7 Handling unknown messages
2.8 Inheritance
2.9 Object: defining the minimal behavior of any object
2.10 Inheritance and instantiation together
2.11 Review of self and super semantics
2.12 Object creation
2.13 Creation of instances of the class Point
2.14 Creation of the class Point instance of Class
2.15 The Class class
2.16 Conclusion
3 First metaclasses
3.1 Defining a new Metaclass
3.2 About class state
3.3 About the 6th postulate
3.4 Conclusion
4 Getting started with the implementation
4.1 Preparation
4.2 Naming conventions
4.3 Helping develop the kernel
4.4 Inheriting from class Array
4.5 Facilitating objClass class access
5 Primitives for a reflective class-based kernel
5.1 Structure and primitives
5.2 Structure of a class
5.3 Finding the class of an object
5.4 Accessing object instance variable values
5.5 Object allocation and initialization
5.6 Keywords primitives
5.7 Object initialization
5.8 Static inheritance of instance variables
5.9 Method management
5.10 Message passing and dynamic lookup
5.11 Method lookup
5.12 Managing super
5.13 Representing super
5.14 Handling not understood messages
6 Defining the language kernel
6.1 About bootstrap
6.2 Manually creating ObjClass
6.3 Creation of ObjObject
6.4 Creation of ObjClass
6.5 First User Classes: ObjPoint
6.6 First User Classes: ObjColoredPoint
6.7 A First User Metaclass: ObjAbstract
6.8 New features that you could implement
7 Selected definitions
Bibliography
Back in the early 90’s, when I was a student, built a theorem proving system in Common Lisp Object System. It was a fun first contact with object-oriented programming, even if at the time I did not master all the aspects. The following year, we got an excellent lecture onmeta-object programming by M. Blay Fornarino. I loved the lecture where we program metaclasses and mixins. I realize now that it was quite advanced.
However, deep inside me, I knew that I did not fully understand what was the class Object or what was really a metaclass. Of course, I could repeat the lecture and look smart, but there was this little voice telling me that I wasn’t 100% sure. Then, I read the article of Pierre Cointe on ObjVlisp. I got blasted by the simplicity of the model. I spent the next 2 days reimplementing the model because it was too much fun. For me, it is the key to my deep understanding of class-based reflective systems. Once I finished implementing it, I went to see my teacher and told her that she must teach it. She told me to do it. Since then I’ve been teaching it.
Note that while the project is historically named ObjVlisp, it has not much to do with LISP. This kernel is similar to the one of Smalltalk-78 with explicit metaclasses. ObjVlisp is just a little conceptual framework but it provides a condensed view and explains the forces present in larger systems such as Pharo that share the everything is an object mantra I love so much.
This book explains the consequence of having classes as objects. In addition, it describes the design and the consequences of having a self-described reflective minimal kernel.
By doing so we will learn deeply about objects, object creation instantiation, message lookup, delegation, inheritance, and much more.
I would like to thank Christopher Fuhrman for his large copy-edit pass and kksubbu, Imen Sayar, and René-Paul for their suggestions.
— S. Ducasse
