SlideShare a Scribd company logo
1 of 41
Download to read offline
Reļ¬‚ection




  Marcus Denker
  denker@iam.unibe.ch

  UniversitƤt Bern




Ā© Marcus Denker
Roadmap




> Introduction: Reļ¬‚ection
> I. Sub-Method Structural Reļ¬‚ection
> II. Partial Behavioral Reļ¬‚ection




Ā© Marcus Denker
Roadmap




> Introduction: Reļ¬‚ection
> I. Sub-Method Structural Reļ¬‚ection
> II. Partial Behavioral Reļ¬‚ection




Ā© Marcus Denker
System




Deļ¬nition:

A computational system is a computer-based system
whose purpose is to answer questions and/or support
actions about some domain.
                  (P. Maes, ā€œConcepts and Experiments in
                  Computational Reļ¬‚ection," Proceedings of OOPLA 87)




Ā© Marcus Denker
Causally Connected




Deļ¬nition:

A system is said to be causally connected to its domain if
the internal structures and the domain they represent are
linked in such a way that if one of them changes, this leads
to a corresponding effect of the other.



                                         (Patty Maes, OOPSLA 87)

Ā© Marcus Denker
Reļ¬‚ective System




Deļ¬nition:

A reļ¬‚ective system is a system which incorporates
causally connected structures representing (aspects of)
itself.

                                        (Patty Maes, OOPSLA 87)




Ā© Marcus Denker
Introspection



>    Introspection
     ā€” Self-representation can be queried

>    Intercession
     ā€” Self-representation can be changed




           Reļ¬‚ection = Introspection + Intercession


Ā© Marcus Denker
Structure and Behavior




>    Structural Reļ¬‚ection
     ā€” Concerned with static structure
     ā€” For example: packages, data-types, procedures

>    Behavioral Reļ¬‚ection
     ā€” Concerned with execution
     ā€” For example: procedure execution, assignment, variable read




Ā© Marcus Denker
Tower of Interpreters



>    First studied for
     procedural languages

>    David A. Smith: 3Lisp        Interpreter at level 3

                                  Interpreter at level 2
>    Tower-of-Interpreters
                                  Interpreter at level 1

>    Theoretical. Slow!      User Program running a level 0




Ā© Marcus Denker
Reļ¬‚ection and OOP


>    A good match: self-representation build of objects
     ā€” Better then interpreter data-structures


>    Language-based reļ¬‚ection
     ā€” Language entities represented as objects
     ā€” Meta-objects describe behavior of base level objects

> Structure: classes/methods are objects
> Behavior: meta-objects deļ¬ne behavior
     ā€” Example: meta-class deļ¬nes method lookup


Ā© Marcus Denker
Example: Java


>    Structural introspection
     ā€” java.lang.reļ¬‚ect
     ā€” Query a model of the program (classes, protocols)


>    Limited intercession
     ā€” No change of classes

>    Limited behavioral reļ¬‚ection
     ā€” Wrappers on objects
     ā€” No way to intercept method calls, variable access


Ā© Marcus Denker
Example: Squeak



>    Squeak has support for reļ¬‚ection

>    Structural reļ¬‚ection
     ā€” Classes / methods are objects
     ā€” Can be changed at runtime

>    Behavioral reļ¬‚ection
     ā€” Current execution reiļ¬ed (thisContext)
     ā€” #doesNotUnderstand / MethodWrappers



Ā© Marcus Denker
Can we do better?


>    Structural Reļ¬‚ection stops at method level
     ā€” Bytecode in the CompiledMethod: Numbers
     ā€” Text: Just a String, needs to be compiled

>    Behavior hard coded in the Virtual Machine
     ā€” Message Sending
     ā€” Variable Access

>    Both structural and behavioral reļ¬‚ection is limited
     ā€” We should do better!


Ā© Marcus Denker
Roadmap




> Introduction: Reļ¬‚ection
> I. Sub-Method Structural Reļ¬‚ection
> II. Partial Behavioral Reļ¬‚ection




Ā© Marcus Denker
Structural Reļ¬‚ection



>    Structure modeled as objects

     ā€” e.g. Classes, methods
     ā€” Causally connected

>    Uses:
     ā€” Development environments
     ā€” Language extensions and experiments




Ā© Marcus Denker
Methods and Reļ¬‚ection



>    Method are Objects
     ā€” e.g in Smalltalk


>    No high-level model for sub-method elements
     ā€” Message sends
     ā€” Assignments
     ā€” Variable access


>    Structural reļ¬‚ection stops at the granularity of methods


Ā© Marcus Denker
Sub-Method Reļ¬‚ection



>    Many tools work on sub method level
     ā€” Proļ¬ler, Refactoring Tool, Debugger, Type Checker

>    Communication between tools needed
     ā€” Example: Code coverage

>    All tools use different representations
     ā€” Tools are harder to build
     ā€” Communication not possible


Ā© Marcus Denker
Existing Method Representations




>    Existing representations for Methods

     ā€” Text

     ā€” Bytecode

     ā€” AST




Ā© Marcus Denker
Requirements


>    Causal Connection

>    Abstraction Level

>    Extensibility

>    Persistency

>    Size and Performance


Ā© Marcus Denker
Text




>    Low level abstraction
     ā€” String of characters


>    Not causally connected
     ā€” Need to call compiler




Ā© Marcus Denker
Bytecode



>    Low level abstraction
     ā€” Array of Integers


>    Missing extensibility
     ā€” e.g. for tools

>    Mix of base- and meta-level code
     ā€” Problems with synthesized code when changing code
     ā€” Examples: AOP point-cut residues, reļ¬‚ection hooks



Ā© Marcus Denker
Abstract Syntax Tree



>    Not causally connected
     ā€” Need to call compiler


>    Not extensible
     ā€” Fixed set of codes, no way to store meta data

>    Not persistent
     ā€” Generated by compiler from text, never stored




Ā© Marcus Denker
Solution: Reļ¬‚ective Methods


> Annotated, persistent AST
> Bytecode generated on demand and cached


    :Reļ¬‚ectiveMethod                                           :CompiledMethod
                     annotation               compiledMethod

                                                               #(12 13 45 38 98 128
                     annotation
                                  reļ¬‚ectiveMethod              84 72 42 77 22 28 59
                                                                 32 7 49 51 87 64)




             Tools                                                     VM



Ā© Marcus Denker
Persephone



>    Implementation of Reļ¬‚ective Methods for Squeak

>    Smalltalk compiler generates Reļ¬‚ective Methods
     ā€” Translated to bytecode on demand

>    Open Compiler: Plugins
     ā€” Called before code generation
     ā€” Transform a copy of the AST




Ā© Marcus Denker
Requirements revisited


>    Abstraction Level OK

>    Causal Connection OK

>    Extensibility OK

>    Persistency OK

>    Size and Performance OK


Ā© Marcus Denker
Annotations


>    Source visible annotations
     ā€” extended Smalltalk syntax

                  (9 raisedTo: 10000) <:evaluateAtCompiletime:>

>    Source invisible annotations
     ā€” Reļ¬‚ective API
     ā€” Can reference any object

> Every node can be annotated
> Semantics: Compiler Plugins


Ā© Marcus Denker
Example: Pluggable Type-System


>    Example for textual annotations


      bitFromBoolean: aBoolean <:type: Boolean :>
      ^ (aBoolean ifTrue: [1] ifFalse: [0]) <:type: Integer :>




> Optional, pluggable type-system
> Types stored as annotations in the Reļ¬‚ective Methods



Ā© Marcus Denker
Memory




                            number of classes memory


     Squeak 3.9             2040             15.7 MB


     Persephone             2224             20 MB
     no reļ¬‚ective methods

     Persephone             2224             123 MB
     reļ¬‚ective methods


Ā© Marcus Denker
Roadmap




> Introduction: Reļ¬‚ection in Squeak
> I. Sub-Method Structural Reļ¬‚ection
> II. Partial Behavioral Reļ¬‚ection




Ā© Marcus Denker
Behavioral Reļ¬‚ection


>    Reļ¬‚ect on the execution
     ā€” method execution
     ā€” message sending, variable access

>    In Smalltalk
     ā€” No model of execution below method body
     ā€” message sending / variable access hard coded by VM
     ā€” #doesNotUnderstand / MethodWrappers

>    Reļ¬‚ective capabilities of Smalltalk should be improved!


Ā© Marcus Denker
MetaclassTalk


>    Extends the Smalltalk metaclass model
     ā€” Similar to CLOS MOP


>    Metaclass deļ¬nes
     ā€” message lookup
     ā€” access to instance variables

>    Problems:
     ā€” Reļ¬‚ection only controllable at class boundaries
     ā€” No ļ¬ne-grained selection (e.g. single operations)
     ā€” Protocol between base and meta level is ļ¬xed


Ā© Marcus Denker
Reļ¬‚ex: Partial Behavioral Reļ¬‚ection


> Hooksets: collection of operation occurrences
> Links
     ā€” Bind hooksets to meta-objects
     ā€” Deļ¬ne protocol between base and meta
                                                           metaobject
>    Goals
     ā€” Highly selective reiļ¬cation   links                 activation
                                                           condition
     ā€” Flexible meta-level engineering
           ā€“      Protocol speciļ¬cation                     hookset
           ā€“      Cross-cutting hooksets

                                              Tanter, OOPSLA03
Ā© Marcus Denker
Example: Proļ¬ler



>    Operation:
     ā€” Method execution (around)


>    Hookset:
     ā€” All execution operations in a package

                                               metaobject
>    Meta-object:
     ā€” A proļ¬ling tool             links       activation
                                               condition

                                                hookset

Ā© Marcus Denker
Reļ¬‚ex for Squeak




>    Partial Behavioral Reļ¬‚ection pioneered in Java
     ā€” Code transformation at load time
     ā€” Not unanticipated (itŹ¼s Java...)



>    Geppetto: Partial Behavioral Reļ¬‚ection for Smalltalk
     ā€” For Squeak 3.9 with Bytecode transformation




Ā© Marcus Denker
Problems


>    Annotation performance
     ā€” Decompile bytecode


>    Execution performance
     ā€” Preambles for stack manipulation

>    Low-level representation
     ā€” ifTrue:ifFalse:
     ā€” Blocks
     ā€” Global variables


Ā© Marcus Denker
Links as Annotations

>    Links can be annotations on the AST

            Method
                                           Meta
                        Link




Ā© Marcus Denker
Properties



>    Very fast annotations
     ā€” No decompile!

>    On-the-ļ¬‚y code generation
     ā€” Only code executed gets generated

>    Generated code is fast
     ā€” Better then working on bytecode level




Ā© Marcus Denker
Demo




>    Show Bounce Demo




Ā© Marcus Denker
Reļ¬‚ectivity




>    Prototype implementation in Squeak

     ā€” Sub-Method Structure
     ā€” Partial Behavioral Reļ¬‚ection

>    Download:
    http:/scg.unibe.ch/Research/Reflectivity



Ā© Marcus Denker
WhatŹ¼s next...




>    Optimize Size of AST Representation
     ā€” Simpler AST
     ā€” AST Compression

>    Beyond Text
     ā€” Store only AST (no text)
     ā€” Build text from annotated AST




Ā© Marcus Denker
License

>    http://creativecommons.org/licenses/by-sa/2.5/



                                           Attribution-ShareAlike 2.5
     You are free:
     ā€¢ to copy, distribute, display, and perform the work
     ā€¢ to make derivative works
     ā€¢ to make commercial use of the work

     Under the following conditions:

              Attribution. You must attribute the work in the manner speciļ¬ed by the author or licensor.

     
              Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting
              work only under a license identical to this one.

     ā€¢ For any reuse or distribution, you must make clear to others the license terms of this work.
     ā€¢ Any of these conditions can be waived if you get permission from the copyright holder.

                     Your fair use and other rights are in no way affected by the above.
Ā© Marcus Denker

More Related Content

What's hot

Performance evaluation of larger matrices over cluster of four nodes using mpi
Performance evaluation of larger matrices over cluster of four nodes using mpiPerformance evaluation of larger matrices over cluster of four nodes using mpi
Performance evaluation of larger matrices over cluster of four nodes using mpieSAT Journals
Ā 
dos mutual exclusion algos
dos mutual exclusion algosdos mutual exclusion algos
dos mutual exclusion algosAkhil Sharma
Ā 
Ch4 OS
Ch4 OSCh4 OS
Ch4 OSC.U
Ā 
Process
ProcessProcess
ProcessSachin MK
Ā 
An Overview of Distributed Debugging
An Overview of Distributed DebuggingAn Overview of Distributed Debugging
An Overview of Distributed DebuggingAnant Narayanan
Ā 
resource management
  resource management  resource management
resource managementAshish Kumar
Ā 
Error tolerant resource allocation and payment minimization for cloud system
Error tolerant resource allocation and payment minimization for cloud systemError tolerant resource allocation and payment minimization for cloud system
Error tolerant resource allocation and payment minimization for cloud systemIEEEFINALYEARPROJECTS
Ā 
DOTNET 2013 IEEE CLOUDCOMPUTING PROJECT Error tolerant resource allocation an...
DOTNET 2013 IEEE CLOUDCOMPUTING PROJECT Error tolerant resource allocation an...DOTNET 2013 IEEE CLOUDCOMPUTING PROJECT Error tolerant resource allocation an...
DOTNET 2013 IEEE CLOUDCOMPUTING PROJECT Error tolerant resource allocation an...IEEEGLOBALSOFTTECHNOLOGIES
Ā 
Final jaypaper linux
Final jaypaper linuxFinal jaypaper linux
Final jaypaper linuxjaya380
Ā 
(Slides) Task scheduling algorithm for multicore processor system for minimiz...
(Slides) Task scheduling algorithm for multicore processor system for minimiz...(Slides) Task scheduling algorithm for multicore processor system for minimiz...
(Slides) Task scheduling algorithm for multicore processor system for minimiz...Naoki Shibata
Ā 
Resource Management for Computer Operating Systems
Resource Management for Computer Operating SystemsResource Management for Computer Operating Systems
Resource Management for Computer Operating Systemsinside-BigData.com
Ā 
Resource management
Resource managementResource management
Resource managementpeeyushanand6
Ā 
CS6601 DISTRIBUTED SYSTEMS
CS6601 DISTRIBUTED SYSTEMSCS6601 DISTRIBUTED SYSTEMS
CS6601 DISTRIBUTED SYSTEMSKathirvel Ayyaswamy
Ā 
Lec 4 (program and network properties)
Lec 4 (program and network properties)Lec 4 (program and network properties)
Lec 4 (program and network properties)Sudarshan Mondal
Ā 
System Structure for Dependable Software Systems
System Structure for Dependable Software SystemsSystem Structure for Dependable Software Systems
System Structure for Dependable Software SystemsVincenzo De Florio
Ā 
Computer Network Performance evaluation based on Network scalability using OM...
Computer Network Performance evaluation based on Network scalability using OM...Computer Network Performance evaluation based on Network scalability using OM...
Computer Network Performance evaluation based on Network scalability using OM...Jaipal Dhobale
Ā 

What's hot (20)

Ch4
Ch4Ch4
Ch4
Ā 
Performance evaluation of larger matrices over cluster of four nodes using mpi
Performance evaluation of larger matrices over cluster of four nodes using mpiPerformance evaluation of larger matrices over cluster of four nodes using mpi
Performance evaluation of larger matrices over cluster of four nodes using mpi
Ā 
dos mutual exclusion algos
dos mutual exclusion algosdos mutual exclusion algos
dos mutual exclusion algos
Ā 
OS_Ch4
OS_Ch4OS_Ch4
OS_Ch4
Ā 
Ch4 OS
Ch4 OSCh4 OS
Ch4 OS
Ā 
Process
ProcessProcess
Process
Ā 
An Overview of Distributed Debugging
An Overview of Distributed DebuggingAn Overview of Distributed Debugging
An Overview of Distributed Debugging
Ā 
resource management
  resource management  resource management
resource management
Ā 
Error tolerant resource allocation and payment minimization for cloud system
Error tolerant resource allocation and payment minimization for cloud systemError tolerant resource allocation and payment minimization for cloud system
Error tolerant resource allocation and payment minimization for cloud system
Ā 
DOTNET 2013 IEEE CLOUDCOMPUTING PROJECT Error tolerant resource allocation an...
DOTNET 2013 IEEE CLOUDCOMPUTING PROJECT Error tolerant resource allocation an...DOTNET 2013 IEEE CLOUDCOMPUTING PROJECT Error tolerant resource allocation an...
DOTNET 2013 IEEE CLOUDCOMPUTING PROJECT Error tolerant resource allocation an...
Ā 
5. Distributed Operating Systems
5. Distributed Operating Systems5. Distributed Operating Systems
5. Distributed Operating Systems
Ā 
Final jaypaper linux
Final jaypaper linuxFinal jaypaper linux
Final jaypaper linux
Ā 
(Slides) Task scheduling algorithm for multicore processor system for minimiz...
(Slides) Task scheduling algorithm for multicore processor system for minimiz...(Slides) Task scheduling algorithm for multicore processor system for minimiz...
(Slides) Task scheduling algorithm for multicore processor system for minimiz...
Ā 
Resource Management for Computer Operating Systems
Resource Management for Computer Operating SystemsResource Management for Computer Operating Systems
Resource Management for Computer Operating Systems
Ā 
Resource management
Resource managementResource management
Resource management
Ā 
CS6601 DISTRIBUTED SYSTEMS
CS6601 DISTRIBUTED SYSTEMSCS6601 DISTRIBUTED SYSTEMS
CS6601 DISTRIBUTED SYSTEMS
Ā 
Lec 4 (program and network properties)
Lec 4 (program and network properties)Lec 4 (program and network properties)
Lec 4 (program and network properties)
Ā 
System Structure for Dependable Software Systems
System Structure for Dependable Software SystemsSystem Structure for Dependable Software Systems
System Structure for Dependable Software Systems
Ā 
Computer Network Performance evaluation based on Network scalability using OM...
Computer Network Performance evaluation based on Network scalability using OM...Computer Network Performance evaluation based on Network scalability using OM...
Computer Network Performance evaluation based on Network scalability using OM...
Ā 
10. resource management
10. resource management10. resource management
10. resource management
Ā 

Similar to Reflection in Smalltalk: Structural and Behavioral Concepts

Reflectivity Demo
Reflectivity DemoReflectivity Demo
Reflectivity DemoMarcus Denker
Ā 
Beyond Text - Methods as Objects
Beyond Text - Methods as ObjectsBeyond Text - Methods as Objects
Beyond Text - Methods as ObjectsMarcus Denker
Ā 
Unanticipated Partial Behavioral Reflection
Unanticipated Partial Behavioral ReflectionUnanticipated Partial Behavioral Reflection
Unanticipated Partial Behavioral ReflectionESUG
Ā 
Unanticipated Partial Behavioral Reflection
Unanticipated Partial Behavioral ReflectionUnanticipated Partial Behavioral Reflection
Unanticipated Partial Behavioral ReflectionMarcus Denker
Ā 
Sub-Method Reflection
Sub-Method ReflectionSub-Method Reflection
Sub-Method ReflectionMarcus Denker
Ā 
Demo: Reflectivity
Demo: ReflectivityDemo: Reflectivity
Demo: ReflectivityMarcus Denker
Ā 
The Reflectivity
The ReflectivityThe Reflectivity
The ReflectivityESUG
Ā 
Presentation about my Research
Presentation about my ResearchPresentation about my Research
Presentation about my ResearchMarcus Denker
Ā 
Talk: Practical, Pluggable Types
Talk: Practical, Pluggable TypesTalk: Practical, Pluggable Types
Talk: Practical, Pluggable TypesMarcus Denker
Ā 
Software Evolution from the Field: an Experience Report
Software Evolution from the Field: an Experience ReportSoftware Evolution from the Field: an Experience Report
Software Evolution from the Field: an Experience ReportMarcus Denker
Ā 
Behavioral Reflection
Behavioral ReflectionBehavioral Reflection
Behavioral ReflectionMarcus Denker
Ā 
The meta of Meta-object Architectures
The meta of Meta-object ArchitecturesThe meta of Meta-object Architectures
The meta of Meta-object ArchitecturesMarcus Denker
Ā 
Crafted Design - GeeCON 2014
Crafted Design - GeeCON 2014Crafted Design - GeeCON 2014
Crafted Design - GeeCON 2014Sandro Mancuso
Ā 
DDD, CQRS and testing with ASP.Net MVC
DDD, CQRS and testing with ASP.Net MVCDDD, CQRS and testing with ASP.Net MVC
DDD, CQRS and testing with ASP.Net MVCAndy Butland
Ā 
Command Design Pattern
Command Design PatternCommand Design Pattern
Command Design PatternRothana Choun
Ā 
Andrii Sliusar "Module Architecture of React-Redux Applications"
Andrii Sliusar "Module Architecture of React-Redux Applications"Andrii Sliusar "Module Architecture of React-Redux Applications"
Andrii Sliusar "Module Architecture of React-Redux Applications"LogeekNightUkraine
Ā 

Similar to Reflection in Smalltalk: Structural and Behavioral Concepts (20)

Reflection
ReflectionReflection
Reflection
Ā 
Reflectivity Demo
Reflectivity DemoReflectivity Demo
Reflectivity Demo
Ā 
Beyond Text - Methods as Objects
Beyond Text - Methods as ObjectsBeyond Text - Methods as Objects
Beyond Text - Methods as Objects
Ā 
Unanticipated Partial Behavioral Reflection
Unanticipated Partial Behavioral ReflectionUnanticipated Partial Behavioral Reflection
Unanticipated Partial Behavioral Reflection
Ā 
Unanticipated Partial Behavioral Reflection
Unanticipated Partial Behavioral ReflectionUnanticipated Partial Behavioral Reflection
Unanticipated Partial Behavioral Reflection
Ā 
Sub-Method Reflection
Sub-Method ReflectionSub-Method Reflection
Sub-Method Reflection
Ā 
Demo: Reflectivity
Demo: ReflectivityDemo: Reflectivity
Demo: Reflectivity
Ā 
The Reflectivity
The ReflectivityThe Reflectivity
The Reflectivity
Ā 
Presentation about my Research
Presentation about my ResearchPresentation about my Research
Presentation about my Research
Ā 
Unstuck
UnstuckUnstuck
Unstuck
Ā 
Talk: Practical, Pluggable Types
Talk: Practical, Pluggable TypesTalk: Practical, Pluggable Types
Talk: Practical, Pluggable Types
Ā 
Software Evolution from the Field: an Experience Report
Software Evolution from the Field: an Experience ReportSoftware Evolution from the Field: an Experience Report
Software Evolution from the Field: an Experience Report
Ā 
Behavioral Reflection
Behavioral ReflectionBehavioral Reflection
Behavioral Reflection
Ā 
08 refactoring
08 refactoring08 refactoring
08 refactoring
Ā 
The meta of Meta-object Architectures
The meta of Meta-object ArchitecturesThe meta of Meta-object Architectures
The meta of Meta-object Architectures
Ā 
Crafted Design - GeeCON 2014
Crafted Design - GeeCON 2014Crafted Design - GeeCON 2014
Crafted Design - GeeCON 2014
Ā 
DDD, CQRS and testing with ASP.Net MVC
DDD, CQRS and testing with ASP.Net MVCDDD, CQRS and testing with ASP.Net MVC
DDD, CQRS and testing with ASP.Net MVC
Ā 
Command Design Pattern
Command Design PatternCommand Design Pattern
Command Design Pattern
Ā 
10 reflection
10 reflection10 reflection
10 reflection
Ā 
Andrii Sliusar "Module Architecture of React-Redux Applications"
Andrii Sliusar "Module Architecture of React-Redux Applications"Andrii Sliusar "Module Architecture of React-Redux Applications"
Andrii Sliusar "Module Architecture of React-Redux Applications"
Ā 

More from Marcus Denker

Soil And Pharo
Soil And PharoSoil And Pharo
Soil And PharoMarcus Denker
Ā 
ConstantBlocks in Pharo11
ConstantBlocks in Pharo11ConstantBlocks in Pharo11
ConstantBlocks in Pharo11Marcus Denker
Ā 
Demo: Improved DoIt
Demo: Improved DoItDemo: Improved DoIt
Demo: Improved DoItMarcus Denker
Ā 
First Class Variables as AST Annotations
First Class Variables as AST AnnotationsFirst Class Variables as AST Annotations
First Class Variables as AST AnnotationsMarcus Denker
Ā 
Supporting Pharo / Getting Pharo Support
Supporting Pharo / Getting Pharo SupportSupporting Pharo / Getting Pharo Support
Supporting Pharo / Getting Pharo SupportMarcus Denker
Ā 
Lecture: "Advanced Reflection: MetaLinks"
Lecture: "Advanced Reflection: MetaLinks"Lecture: "Advanced Reflection: MetaLinks"
Lecture: "Advanced Reflection: MetaLinks"Marcus Denker
Ā 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the DebuggerMarcus Denker
Ā 
Variables in Pharo
Variables in PharoVariables in Pharo
Variables in PharoMarcus Denker
Ā 
Lecture. Advanced Reflection: MetaLinks
Lecture. Advanced Reflection: MetaLinksLecture. Advanced Reflection: MetaLinks
Lecture. Advanced Reflection: MetaLinksMarcus Denker
Ā 
Improving code completion for Pharo
Improving code completion for PharoImproving code completion for Pharo
Improving code completion for PharoMarcus Denker
Ā 
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinksVUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinksMarcus Denker
Ā 
Slot Composition
Slot CompositionSlot Composition
Slot CompositionMarcus Denker
Ā 
Lecture: Advanced Reflection. MetaLinks
Lecture: Advanced Reflection. MetaLinksLecture: Advanced Reflection. MetaLinks
Lecture: Advanced Reflection. MetaLinksMarcus Denker
Ā 
Open-Source: An Infinite Game
Open-Source: An Infinite GameOpen-Source: An Infinite Game
Open-Source: An Infinite GameMarcus Denker
Ā 
Lecture: MetaLinks
Lecture: MetaLinksLecture: MetaLinks
Lecture: MetaLinksMarcus Denker
Ā 
PharoTechTalk: Contributing to Pharo
PharoTechTalk: Contributing to PharoPharoTechTalk: Contributing to Pharo
PharoTechTalk: Contributing to PharoMarcus Denker
Ā 
Feedback Loops in Practice
Feedback Loops in PracticeFeedback Loops in Practice
Feedback Loops in PracticeMarcus Denker
Ā 
Pharo6 - ESUG17
Pharo6 - ESUG17Pharo6 - ESUG17
Pharo6 - ESUG17Marcus Denker
Ā 

More from Marcus Denker (20)

Soil And Pharo
Soil And PharoSoil And Pharo
Soil And Pharo
Ā 
ConstantBlocks in Pharo11
ConstantBlocks in Pharo11ConstantBlocks in Pharo11
ConstantBlocks in Pharo11
Ā 
Demo: Improved DoIt
Demo: Improved DoItDemo: Improved DoIt
Demo: Improved DoIt
Ā 
First Class Variables as AST Annotations
First Class Variables as AST AnnotationsFirst Class Variables as AST Annotations
First Class Variables as AST Annotations
Ā 
Supporting Pharo / Getting Pharo Support
Supporting Pharo / Getting Pharo SupportSupporting Pharo / Getting Pharo Support
Supporting Pharo / Getting Pharo Support
Ā 
Lecture: "Advanced Reflection: MetaLinks"
Lecture: "Advanced Reflection: MetaLinks"Lecture: "Advanced Reflection: MetaLinks"
Lecture: "Advanced Reflection: MetaLinks"
Ā 
thisContext in the Debugger
thisContext in the DebuggerthisContext in the Debugger
thisContext in the Debugger
Ā 
Variables in Pharo
Variables in PharoVariables in Pharo
Variables in Pharo
Ā 
Lecture. Advanced Reflection: MetaLinks
Lecture. Advanced Reflection: MetaLinksLecture. Advanced Reflection: MetaLinks
Lecture. Advanced Reflection: MetaLinks
Ā 
Improving code completion for Pharo
Improving code completion for PharoImproving code completion for Pharo
Improving code completion for Pharo
Ā 
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinksVUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
VUB Brussels Lecture 2019: Advanced Reflection: MetaLinks
Ā 
Slot Composition
Slot CompositionSlot Composition
Slot Composition
Ā 
Lecture: Advanced Reflection. MetaLinks
Lecture: Advanced Reflection. MetaLinksLecture: Advanced Reflection. MetaLinks
Lecture: Advanced Reflection. MetaLinks
Ā 
PHARO IOT
PHARO IOTPHARO IOT
PHARO IOT
Ā 
Open-Source: An Infinite Game
Open-Source: An Infinite GameOpen-Source: An Infinite Game
Open-Source: An Infinite Game
Ā 
Lecture: MetaLinks
Lecture: MetaLinksLecture: MetaLinks
Lecture: MetaLinks
Ā 
PharoTechTalk: Contributing to Pharo
PharoTechTalk: Contributing to PharoPharoTechTalk: Contributing to Pharo
PharoTechTalk: Contributing to Pharo
Ā 
Feedback Loops in Practice
Feedback Loops in PracticeFeedback Loops in Practice
Feedback Loops in Practice
Ā 
Pharo6 - ESUG17
Pharo6 - ESUG17Pharo6 - ESUG17
Pharo6 - ESUG17
Ā 
Pharo6
Pharo6Pharo6
Pharo6
Ā 

Recently uploaded

šŸ¬ The future of MySQL is Postgres šŸ˜
šŸ¬  The future of MySQL is Postgres   šŸ˜šŸ¬  The future of MySQL is Postgres   šŸ˜
šŸ¬ The future of MySQL is Postgres šŸ˜RTylerCroy
Ā 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
Ā 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
Ā 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGSujit Pal
Ā 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024Rafal Los
Ā 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
Ā 
Finology Group ā€“ Insurtech Innovation Award 2024
Finology Group ā€“ Insurtech Innovation Award 2024Finology Group ā€“ Insurtech Innovation Award 2024
Finology Group ā€“ Insurtech Innovation Award 2024The Digital Insurer
Ā 
Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024BookNet Canada
Ā 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
Ā 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...gurkirankumar98700
Ā 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...HostedbyConfluent
Ā 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
Ā 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
Ā 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Allon Mureinik
Ā 
WhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure servicePooja Nehwal
Ā 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...shyamraj55
Ā 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
Ā 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersThousandEyes
Ā 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
Ā 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
Ā 

Recently uploaded (20)

šŸ¬ The future of MySQL is Postgres šŸ˜
šŸ¬  The future of MySQL is Postgres   šŸ˜šŸ¬  The future of MySQL is Postgres   šŸ˜
šŸ¬ The future of MySQL is Postgres šŸ˜
Ā 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
Ā 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
Ā 
Google AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAGGoogle AI Hackathon: LLM based Evaluator for RAG
Google AI Hackathon: LLM based Evaluator for RAG
Ā 
The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024The 7 Things I Know About Cyber Security After 25 Years | April 2024
The 7 Things I Know About Cyber Security After 25 Years | April 2024
Ā 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
Ā 
Finology Group ā€“ Insurtech Innovation Award 2024
Finology Group ā€“ Insurtech Innovation Award 2024Finology Group ā€“ Insurtech Innovation Award 2024
Finology Group ā€“ Insurtech Innovation Award 2024
Ā 
Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
Transcript: #StandardsGoals for 2024: Whatā€™s new for BISAC - Tech Forum 2024
Ā 
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
Ā 
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Kalyanpur ) Call Girls in Lucknow Finest Escorts Service šŸø 8923113531 šŸŽ° Avail...
Ā 
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Transforming Data Streams with Kafka Connect: An Introduction to Single Messa...
Ā 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
Ā 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Ā 
Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)Injustice - Developers Among Us (SciFiDevCon 2024)
Injustice - Developers Among Us (SciFiDevCon 2024)
Ā 
WhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure serviceWhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure service
WhatsApp 9892124323 āœ“Call Girls In Kalyan ( Mumbai ) secure service
Ā 
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Automating Business Process via MuleSoft Composer | Bangalore MuleSoft Meetup...
Ā 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
Ā 
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for PartnersEnhancing Worker Digital Experience: A Hands-on Workshop for Partners
Enhancing Worker Digital Experience: A Hands-on Workshop for Partners
Ā 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
Ā 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
Ā 

Reflection in Smalltalk: Structural and Behavioral Concepts

  • 1. Reļ¬‚ection Marcus Denker denker@iam.unibe.ch UniversitƤt Bern Ā© Marcus Denker
  • 2. Roadmap > Introduction: Reļ¬‚ection > I. Sub-Method Structural Reļ¬‚ection > II. Partial Behavioral Reļ¬‚ection Ā© Marcus Denker
  • 3. Roadmap > Introduction: Reļ¬‚ection > I. Sub-Method Structural Reļ¬‚ection > II. Partial Behavioral Reļ¬‚ection Ā© Marcus Denker
  • 4. System Deļ¬nition: A computational system is a computer-based system whose purpose is to answer questions and/or support actions about some domain. (P. Maes, ā€œConcepts and Experiments in Computational Reļ¬‚ection," Proceedings of OOPLA 87) Ā© Marcus Denker
  • 5. Causally Connected Deļ¬nition: A system is said to be causally connected to its domain if the internal structures and the domain they represent are linked in such a way that if one of them changes, this leads to a corresponding effect of the other. (Patty Maes, OOPSLA 87) Ā© Marcus Denker
  • 6. Reļ¬‚ective System Deļ¬nition: A reļ¬‚ective system is a system which incorporates causally connected structures representing (aspects of) itself. (Patty Maes, OOPSLA 87) Ā© Marcus Denker
  • 7. Introspection > Introspection ā€” Self-representation can be queried > Intercession ā€” Self-representation can be changed Reļ¬‚ection = Introspection + Intercession Ā© Marcus Denker
  • 8. Structure and Behavior > Structural Reļ¬‚ection ā€” Concerned with static structure ā€” For example: packages, data-types, procedures > Behavioral Reļ¬‚ection ā€” Concerned with execution ā€” For example: procedure execution, assignment, variable read Ā© Marcus Denker
  • 9. Tower of Interpreters > First studied for procedural languages > David A. Smith: 3Lisp Interpreter at level 3 Interpreter at level 2 > Tower-of-Interpreters Interpreter at level 1 > Theoretical. Slow! User Program running a level 0 Ā© Marcus Denker
  • 10. Reļ¬‚ection and OOP > A good match: self-representation build of objects ā€” Better then interpreter data-structures > Language-based reļ¬‚ection ā€” Language entities represented as objects ā€” Meta-objects describe behavior of base level objects > Structure: classes/methods are objects > Behavior: meta-objects deļ¬ne behavior ā€” Example: meta-class deļ¬nes method lookup Ā© Marcus Denker
  • 11. Example: Java > Structural introspection ā€” java.lang.reļ¬‚ect ā€” Query a model of the program (classes, protocols) > Limited intercession ā€” No change of classes > Limited behavioral reļ¬‚ection ā€” Wrappers on objects ā€” No way to intercept method calls, variable access Ā© Marcus Denker
  • 12. Example: Squeak > Squeak has support for reļ¬‚ection > Structural reļ¬‚ection ā€” Classes / methods are objects ā€” Can be changed at runtime > Behavioral reļ¬‚ection ā€” Current execution reiļ¬ed (thisContext) ā€” #doesNotUnderstand / MethodWrappers Ā© Marcus Denker
  • 13. Can we do better? > Structural Reļ¬‚ection stops at method level ā€” Bytecode in the CompiledMethod: Numbers ā€” Text: Just a String, needs to be compiled > Behavior hard coded in the Virtual Machine ā€” Message Sending ā€” Variable Access > Both structural and behavioral reļ¬‚ection is limited ā€” We should do better! Ā© Marcus Denker
  • 14. Roadmap > Introduction: Reļ¬‚ection > I. Sub-Method Structural Reļ¬‚ection > II. Partial Behavioral Reļ¬‚ection Ā© Marcus Denker
  • 15. Structural Reļ¬‚ection > Structure modeled as objects ā€” e.g. Classes, methods ā€” Causally connected > Uses: ā€” Development environments ā€” Language extensions and experiments Ā© Marcus Denker
  • 16. Methods and Reļ¬‚ection > Method are Objects ā€” e.g in Smalltalk > No high-level model for sub-method elements ā€” Message sends ā€” Assignments ā€” Variable access > Structural reļ¬‚ection stops at the granularity of methods Ā© Marcus Denker
  • 17. Sub-Method Reļ¬‚ection > Many tools work on sub method level ā€” Proļ¬ler, Refactoring Tool, Debugger, Type Checker > Communication between tools needed ā€” Example: Code coverage > All tools use different representations ā€” Tools are harder to build ā€” Communication not possible Ā© Marcus Denker
  • 18. Existing Method Representations > Existing representations for Methods ā€” Text ā€” Bytecode ā€” AST Ā© Marcus Denker
  • 19. Requirements > Causal Connection > Abstraction Level > Extensibility > Persistency > Size and Performance Ā© Marcus Denker
  • 20. Text > Low level abstraction ā€” String of characters > Not causally connected ā€” Need to call compiler Ā© Marcus Denker
  • 21. Bytecode > Low level abstraction ā€” Array of Integers > Missing extensibility ā€” e.g. for tools > Mix of base- and meta-level code ā€” Problems with synthesized code when changing code ā€” Examples: AOP point-cut residues, reļ¬‚ection hooks Ā© Marcus Denker
  • 22. Abstract Syntax Tree > Not causally connected ā€” Need to call compiler > Not extensible ā€” Fixed set of codes, no way to store meta data > Not persistent ā€” Generated by compiler from text, never stored Ā© Marcus Denker
  • 23. Solution: Reļ¬‚ective Methods > Annotated, persistent AST > Bytecode generated on demand and cached :Reļ¬‚ectiveMethod :CompiledMethod annotation compiledMethod #(12 13 45 38 98 128 annotation reļ¬‚ectiveMethod 84 72 42 77 22 28 59 32 7 49 51 87 64) Tools VM Ā© Marcus Denker
  • 24. Persephone > Implementation of Reļ¬‚ective Methods for Squeak > Smalltalk compiler generates Reļ¬‚ective Methods ā€” Translated to bytecode on demand > Open Compiler: Plugins ā€” Called before code generation ā€” Transform a copy of the AST Ā© Marcus Denker
  • 25. Requirements revisited > Abstraction Level OK > Causal Connection OK > Extensibility OK > Persistency OK > Size and Performance OK Ā© Marcus Denker
  • 26. Annotations > Source visible annotations ā€” extended Smalltalk syntax (9 raisedTo: 10000) <:evaluateAtCompiletime:> > Source invisible annotations ā€” Reļ¬‚ective API ā€” Can reference any object > Every node can be annotated > Semantics: Compiler Plugins Ā© Marcus Denker
  • 27. Example: Pluggable Type-System > Example for textual annotations bitFromBoolean: aBoolean <:type: Boolean :> ^ (aBoolean ifTrue: [1] ifFalse: [0]) <:type: Integer :> > Optional, pluggable type-system > Types stored as annotations in the Reļ¬‚ective Methods Ā© Marcus Denker
  • 28. Memory number of classes memory Squeak 3.9 2040 15.7 MB Persephone 2224 20 MB no reļ¬‚ective methods Persephone 2224 123 MB reļ¬‚ective methods Ā© Marcus Denker
  • 29. Roadmap > Introduction: Reļ¬‚ection in Squeak > I. Sub-Method Structural Reļ¬‚ection > II. Partial Behavioral Reļ¬‚ection Ā© Marcus Denker
  • 30. Behavioral Reļ¬‚ection > Reļ¬‚ect on the execution ā€” method execution ā€” message sending, variable access > In Smalltalk ā€” No model of execution below method body ā€” message sending / variable access hard coded by VM ā€” #doesNotUnderstand / MethodWrappers > Reļ¬‚ective capabilities of Smalltalk should be improved! Ā© Marcus Denker
  • 31. MetaclassTalk > Extends the Smalltalk metaclass model ā€” Similar to CLOS MOP > Metaclass deļ¬nes ā€” message lookup ā€” access to instance variables > Problems: ā€” Reļ¬‚ection only controllable at class boundaries ā€” No ļ¬ne-grained selection (e.g. single operations) ā€” Protocol between base and meta level is ļ¬xed Ā© Marcus Denker
  • 32. Reļ¬‚ex: Partial Behavioral Reļ¬‚ection > Hooksets: collection of operation occurrences > Links ā€” Bind hooksets to meta-objects ā€” Deļ¬ne protocol between base and meta metaobject > Goals ā€” Highly selective reiļ¬cation links activation condition ā€” Flexible meta-level engineering ā€“ Protocol speciļ¬cation hookset ā€“ Cross-cutting hooksets Tanter, OOPSLA03 Ā© Marcus Denker
  • 33. Example: Proļ¬ler > Operation: ā€” Method execution (around) > Hookset: ā€” All execution operations in a package metaobject > Meta-object: ā€” A proļ¬ling tool links activation condition hookset Ā© Marcus Denker
  • 34. Reļ¬‚ex for Squeak > Partial Behavioral Reļ¬‚ection pioneered in Java ā€” Code transformation at load time ā€” Not unanticipated (itŹ¼s Java...) > Geppetto: Partial Behavioral Reļ¬‚ection for Smalltalk ā€” For Squeak 3.9 with Bytecode transformation Ā© Marcus Denker
  • 35. Problems > Annotation performance ā€” Decompile bytecode > Execution performance ā€” Preambles for stack manipulation > Low-level representation ā€” ifTrue:ifFalse: ā€” Blocks ā€” Global variables Ā© Marcus Denker
  • 36. Links as Annotations > Links can be annotations on the AST Method Meta Link Ā© Marcus Denker
  • 37. Properties > Very fast annotations ā€” No decompile! > On-the-ļ¬‚y code generation ā€” Only code executed gets generated > Generated code is fast ā€” Better then working on bytecode level Ā© Marcus Denker
  • 38. Demo > Show Bounce Demo Ā© Marcus Denker
  • 39. Reļ¬‚ectivity > Prototype implementation in Squeak ā€” Sub-Method Structure ā€” Partial Behavioral Reļ¬‚ection > Download: http:/scg.unibe.ch/Research/Reflectivity Ā© Marcus Denker
  • 40. WhatŹ¼s next... > Optimize Size of AST Representation ā€” Simpler AST ā€” AST Compression > Beyond Text ā€” Store only AST (no text) ā€” Build text from annotated AST Ā© Marcus Denker
  • 41. License > http://creativecommons.org/licenses/by-sa/2.5/ Attribution-ShareAlike 2.5 You are free: ā€¢ to copy, distribute, display, and perform the work ā€¢ to make derivative works ā€¢ to make commercial use of the work Under the following conditions: Attribution. You must attribute the work in the manner speciļ¬ed by the author or licensor. Share Alike. If you alter, transform, or build upon this work, you may distribute the resulting work only under a license identical to this one. ā€¢ For any reuse or distribution, you must make clear to others the license terms of this work. ā€¢ Any of these conditions can be waived if you get permission from the copyright holder. Your fair use and other rights are in no way affected by the above. Ā© Marcus Denker