Implementing Method Definition

To define a method, it is necessary to do several things.

A name is made for the function that implements the method; conventionally, the class name and the selector are hyphenated. The class can be found from the type of the first argument. For example, the method area for class circle will become the function circle-area.

The method code is made into a function definition, then executed using eval.

Finally, an association between the selector and the function name is added to the class.

Contents    Page-10    Prev    Next    Page+10    Index