Metaclasses and Reeection in Smalltalk
نویسنده
چکیده
1 Abstract Many Object-Oriented Programming Languages provide reeective features which may be used to control the interpretive mechanism of the language. Often, these features are deened with respect to a golden braid consisting of objects, classes and metaclasses. This paper describes the Smalltalk golden braid and generalize it for multiple inheritance. Multiple inheritance leads to choices between many diierent inheritance strategies. The reeective features of Smalltalk cannot aaect the basic mechanisms of inheritance and so an arbitrary choice must be made for multiple inheritance. A language is described in which the reeective features of Smalltalk are extended so as to allow programmer deened inheritance strategies. 2 Introduction The evaluation of a programming language expression e in a given context c may be described by the evaluation of a program p which takes a representation of e and c as input. e is termed an object-level construct whilst p and the representations of e and c are termed meta-level constructs. For illustration we use an operator M which maps object-level constructs to meta-level constructs. If the languages which are used for both the object-and meta-levels are the same and causally connected, then the language is reeective 27]. Object-Oriented Programming Languages (OOPLs) have interpretive mechanisms which are based upon classes, object creation, message passing and inheritance. Classes typically deene the local state and operations for objects which are their instances. When a message is passed to an object, the operation with the message name is invoked with respect to the local state. A class inherits from another class by including all the inherited storage and operation deenitions along with its own. The meta-level of an OOPL describes how to perform inheritance, message passing, instance creation etc. If the OOPL is reeective then these mechanisms are described in terms of messages which are sent to objects at the meta-level. Consider the objects at some base level B, the objects and messages which describe how to perform creation of objects at B, message passing at B etc. are deened at level M(B); these objects are called classes. A class at level M(B) is characterized by controlling the creation and subsequent behaviour of a collection of objects at level B. The objects (which are classes) at level M(B) are created and controlled by objects at level M 2 (B); these objects are called metaclasses. A metaclass at level M 2 (B) is characterized by controlling …
منابع مشابه
Programming with ObjVlisp Metaclasses in Smalltalk-80
A b s t r a c t This paper discusses the introduction of explicit metaclasses à la ObjVlisp into the Smalltalk-80 language. The rigidity of Smalltalk metaclass architecture motivated this work. Consequently we decided to implement the ObjVlisp model into the standard Smalltalk-80 system. The resulting combination defines the Classtalk platform. This platform provides a full-size environment to ...
متن کاملExplicit Metaclasses as a Tool for Improving the Design of Class Libraries
Existing OO methodologies focus on instance behaviors and reduce the role of a class to object creation. In fact, these methodologies do not address the issue of class design itself. Nevertheless, classes have their own properties, which are not related to the semantics of their instances. Examples of such properties are wellknown and language independent : concrete vs abstract classes, single ...
متن کاملUniform and safe metaclass composition
In pure object-oriented languages, classes are objects, instances of other classes called metaclasses. In the same way as classes define the properties of their instances, metaclasses define the properties of classes. It is therefore very natural to wish to reuse class properties, utilizing them amongst several classes. However this introduced metaclass composition problems, i.e., code fragment...
متن کاملAspect-oriented Programming versus Reeection: a Rst Draft
Reeection has a long history of dealing about some aspects of software components. In this short position paper, we compare and contrast reeection and aspect-oriented programming. Whilst reeection has recently focused on very speciic aspects of software components, namely implemen-tational usually segregated among structural (representation) and behavioral (execution) aspects, aspect-oriented p...
متن کاملSafe and Explicit Composition of Class Properties
As object-oriented programmers, we are trained to capture common properties of objects in classes that can be reused. Similarly, we would like to capture common properties of classes in metaclass properties that can be reused. This goal has led researchers to propose models based on explicit metaclasses, but this has opened Pandora’s box leading to metaclass composition problems. Numerous appro...
متن کاملذخیره در منابع من
با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید
عنوان ژورنال:
دوره شماره
صفحات -
تاریخ انتشار 1997