Prev | Current Page 19 | Next

Brad Ediger

"Advanced Rails"

This deliberate
misspelling is used everywhere in Ruby.)
iv_tbl
???Instance Variable Table,??? a hashtable containing the instance variables belonging
to this object.
flags
A bitfield of Boolean flags with some status information, such as the object??™s
taint status, garbage collection mark bit, and whether the object is frozen.
Every Ruby class or module has the same fields, plus two more:
m_tbl
???Method Table,??? a hashtable of this class or module??™s instance methods.
super
A pointer to this class or module??™s superclass.
These fields play a huge role in method lookup, and it is important that you understand
them. In particular, you should pay close attention to the difference between
the klass and super pointers of a class object.
The rules
The method lookup rules are very simple, but they depend on an understanding of
how Ruby??™s data structures work. When a message is sent to an object,??  the following
steps occur:
* Except immediate objects (Fixnums, symbols, true, false, and nil); we??™ll get to those later.
??  Ruby often co-opts Smalltalk??™s message-passing terminology: when a method is called, it is said that one is
sending a message. The receiver is the object that the message is sent to.
6 | Chapter 1: Foundational Techniques
1. Ruby follows the receiver??™s klass pointer and searches the m_tbl of that class
object for a matching method.


Pages:
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31