Embodiments of the present invention are directed to a method and apparatus
for extending a program element in a dynamically typed programming language. In
one embodiment, a program element is extended without altering the source code
defining the program element. An extend structure is used to extend a program element
in a particular program. In one embodiment, the program element is a function.
The function is extended by adding code to be executed by the function. In another
embodiment, the program element is an enumeration. The enumeration is extend by
adding additional constants to the enumeration. In another embodiment, the program
element is a class. In one embodiment, a class is extended by adding code to the
constructor of the class. In another embodiment, a class is extended by adding
member variables to the class. In yet another embodiment, a class is extended by
adding member functions to the class.