@@ -10,16 +10,15 @@ h2. Structure of Ruby objects
1010
1111h3. Guideline
1212
13- Starting from this chapter we will explore the `ruby` source code, starting by
14- studying the declaration of objects structures.
13+ In this chapter we will begin exploring the `ruby` source code, starting by
14+ studying the declaration of object structures.
1515
16- What are the required conditions to make sure objects can exist? Many
17- explanations can be given but in reality there are three conditions that must
18- be obeyed:
16+ What do objects need to exist? There are many answers to this question, but for
17+ our purposes an object only needs three things:
1918
20- # Being able to differentiate itself from the rest (having an identity)
21- # Being able to reply to requests (methods)
22- # Keeping an internal state (instance variables)
19+ # The ability to differentiate itself from other objects ( an identity)
20+ # The ability to respond to messages (methods)
21+ # The ability to store internal state (instance variables)
2322
2423In this chapter, we are going to confirm these three features one by one.
2524
@@ -28,9 +27,9 @@ briefly look at other files such as `object.c`, `class.c` or `variable.c`.
2827
2928h3. Structure of `VALUE` and objects
3029
31- In `ruby`, the contents of an object is expressed by a `C` structure, always
32- handled via a pointer. A different kind of structure is used for each class,
33- but the pointer type will always be `VALUE` (figure 1).
30+ In `ruby`, the contents of an object are expressed by a `C` structure, always
31+ handled via a pointer. A different kind of structure is used for each class, but
32+ the pointer type will always be `VALUE` (figure 1).
3433
3534!images/ch_object_value.png(`VALUE` and structure)!
3635
@@ -124,15 +123,15 @@ RARRAY(arr)->len; /* ((struct RArray*)arr)->len */
124123</pre>
125124
126125Another important point to mention is that all object structures start with a
127- member `basic` of type `struct RBasic`. As a result, whatever the type of
128- structure pointed by `VALUE`, if you cast this `VALUE` to `struct RBasic*`,
129- you will be able to access the content of `basic `.
126+ member `basic` of type `struct RBasic`. As a result, if you cast this `VALUE` to
127+ `struct RBasic*`, you will be able to access the content of `basic`, regardless
128+ of the type of structure pointed to by `VALUE `.
130129
131130!images/ch_object_rbasic.png(`struct RBasic`)!
132131
133- You guessed that `struct RBasic` has been designed to contain some important
134- information shared by all object structures. The definition of `struct RBasic`
135- is the following :
132+ You probably guessed that `struct RBasic` has been designed to contain some
133+ important information shared by all object structures. Here is the definition
134+ for `struct RBasic` :
136135
137136▼ `struct RBasic`
138137
@@ -167,9 +166,8 @@ pointer to) a Ruby object. In short, it is a class object.
167166The relation between an object and its class will be detailed in the "Methods"
168167section of this chapter.
169168
170- By the way, the name of this member is not `class` to make sure it does not
171- raise any conflict when the file is processed by a C++ compiler, as it is a
172- reserved word.
169+ By the way, this member is named `klass` so as not to conflict with the reserved
170+ word `class` when the file is processed by a C++ compiler.
173171
174172h4. About structure types
175173
0 commit comments