Download presentation
Presentation is loading. Please wait.
Published byFelicity Elliott Modified over 9 years ago
1
Jim Dowling, DSG. Introduction to Reflection1 Reflection and the Metaobject Protocol paradigm by Jim Dowling
2
Jim Dowling, DSG. Introduction to Reflection2 Reflection Basics Definition: “Computational reflection is the activity of performed by a computational system when doing computation about its own computation [1]” Different reflective approaches - logical, monadic Common notion of access to a “meta” level. Reflection allows programmer to manipulate representations to achieve gains in performance and maintainability [2]
3
Jim Dowling, DSG. Introduction to Reflection3 Some Reflection History Computational reflection generally involves object models –Statically typed object models (C++), dynamically typed object models (Smalltalk) Types categorise objects according to their usage and behaviour In non-reflective object models, these categories (representations) are fixed by programming language designer
4
Jim Dowling, DSG. Introduction to Reflection4 Building Meta-level Architectures Meta-level typing = Meta-type of an object characterises the type of its object model - i.e. the way in which it is implemented [3].
5
Jim Dowling, DSG. Introduction to Reflection5 1. Untyped universe 2. Monomorphic 3. Polymorphic 4. Meta-level types
6
Jim Dowling, DSG. Introduction to Reflection6 Application 1Application n Object model (C++, Smalltalk) Object subsystem (operating system, VM) Hardware Subsystem level Application level The Mile-High Systems View
7
Jim Dowling, DSG. Introduction to Reflection7 Black-box Programming Model Restricted to object model implemented by the language Possibility of application mismatch - applications requirements aren’t met by underlying object subsystem Limited flexibility
8
Jim Dowling, DSG. Introduction to Reflection8 White-box Programming Model Language implementation “opened up” Features of object model implementation can be modified by application programmer Structured interface for making changes Re-categorise objects w.r.t. their usage and behaviour.
9
Jim Dowling, DSG. Introduction to Reflection9 Meta-level Architecture for OOPLs
10
Jim Dowling, DSG. Introduction to Reflection10 Meta-level features of CORBA Extension to OOPL Meta-level information stored in Interface Repository, Implementation Repository A black-box object model ORB is not reflective Ad-hoc additions to add reflective features, e.g. IONA smart stubs - method_before() Trade-offs in implementation. Dynamic invocation 40 times slower than static [4].
11
Jim Dowling, DSG. Introduction to Reflection11 Base-level Meta-level BLO Interface MOP Interface MOPsMLOs BLOs Application Programmer
12
Jim Dowling, DSG. Introduction to Reflection12 Metaobject Protocols (MOPs) Base-level objects (BLOs) Meta-level Objects (MLOs) MOP = collection of MLOs Compile-time MOPs Run-time MOPs Intercessory run-time MOPs Structural run-time MOPs Introspective run-time MOPs Dynamic run-time MOPs [5]
13
Jim Dowling, DSG. Introduction to Reflection13 MOPs as an enabling technology To build a meta-level architecture White-box programming model Behavioural Reflection Structural Reflection Reification of object model features
14
Jim Dowling, DSG. Introduction to Reflection14 Behavioural Reflection Allows program to modify semantics of programming language. Allows program to modify own code. Ability to do this at run-time. Techniques include polymorphism, reflective programming languages, MOPs. Reification of language features Intercession - e.g. method invocation Dynamic Adaption of object model
15
Jim Dowling, DSG. Introduction to Reflection15 Structural Reflection State and/or methods are added or deleted from an object Long life, stable applications Separation of concerns between meta-level and base-level and their implementations
16
Jim Dowling, DSG. Introduction to Reflection16 Reification Every object system contains implementations of the object features supported by it These object features include object creation, message passing, state access, etc. Reification allows these implementations to be modified by the application programmer Essentially making objects first-class data types
17
Jim Dowling, DSG. Introduction to Reflection17 Sample Reification Identify object feature Design event-based model of object model feature to be reified Establish flow of control in actual object model Decide on which events to reify Implement a MOP reifying the object feature.
18
Jim Dowling, DSG. Introduction to Reflection18 Iguana MOP for method invocation
19
Jim Dowling, DSG. Introduction to Reflection19
20
Jim Dowling, DSG. Introduction to Reflection20 History of reflection in DSG Meta-level Architectures Brendan Gowing - Iguana, a Meta-object Protocol for C++ Coyote –Iguana Reflective Programming Model –Focus on building Reflective Middleware / Systems Software
21
Jim Dowling, DSG. Introduction to Reflection21 Conclusion Reflection can make traditionally orthogonal objectives in OO language design compatible: –Flexibility vs. Efficiency –Transparency vs. Level of integration with subsystem Metaobject protocols and reflection blur the distinction between language designer and language user.
22
Jim Dowling, DSG. Introduction to Reflection22 References [1] Maes, Patttie. Concepts and Experiments in Computational Reflection. Sigplan notices, Dec 87, OOPSLA. [2] Friedman, Daniel P. An Exploration of Relationships between Reflective Theories. Proceedings of Reflection ‘96. [3] Cahill Vinny, Iguana Reflective Programming Model, March 98, Draft. [4] Campell Roy et. Al., Reflective ORBs, Dec. 97, ICDS 98. [5] Gowing Brendan, PhD thesis, 1997 [6] Kiczales, Gregor, Art of the MOP, 1991, MIT Press
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.