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, className, 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 className structure so that classes inherit from different classes
  • Generating or modifying the code that defines the methods for the className

Commands of MetaObject

CommandsDiscription
Object

Retrieves an attribute of an instance of the className

MetaMethodRetrieves an instance MetaMethod for the given name and argument values
MetaPropertyReturns 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 className
List<MetaProperty>Obtain a list of all meta properties available on this meta className
classNameSets an attribute of an instance of the className 
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