MetaObject Programming Help by Programmers hub

MetaObject protocol

MetaObject are the object which are used to create the base objects. MetaObject used to manipulates, creates, describes or implements the other objects. MetaObject store the information in the base objects. The information metaobjects store must be object's type, interface, class, methods, attributes, parse tree. metaObject Protocol provides the commands to access and manipulate the structure and behavior of the objects. The functions of the metaobject protocol include:

  • Creating and deleting new classes
  • Creating new methods and properties
  • Changing the class structure so that classes inherit from different classes
  • Generating or modifying the code that defines the methods for the class

Commands of MetaObject

Commands Discription

Retrieves an attribute of an instance of the class

MetaMethod Retrieves an instance MetaMethod for the given name and argument values
MetaProperty Returns a MetaProperty for the given name or null if it doesn't exist
List<MetaMethod> Obtain a list of all the meta methods available on this meta class
List<MetaProperty> Obtain a list of all meta properties available on this meta class
Class Sets an attribute of an instance of the class 
MetaPost Programming Language

When to use MetaObject protocol

  • Memoizing method calls
  • Complex inheritance (this may be of dubious value)
  • Loosening or strengthening a type system
  • Implementing Dynamic Dispatch (if necessary)
  • Persistence
  • Replication