• Like

Loading…

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

Inter-Language Reflection

  • 348 views
Uploaded on

Inter-Language Reflection. Kris Gybels, Roel Wuyts, Maja D’Hondt, Stéphane Ducasse. ESUG 2005, Bruessels

Inter-Language Reflection. Kris Gybels, Roel Wuyts, Maja D’Hondt, Stéphane Ducasse. ESUG 2005, Bruessels

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Be the first to comment
    Be the first to like this
No Downloads

Views

Total Views
348
On Slideshare
0
From Embeds
0
Number of Embeds
0

Actions

Shares
Downloads
3
Comments
0
Likes
0

Embeds 0

No embeds

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
    No notes for slide

Transcript

  • 1. Kris Gybels Roel Wuyts Maja D’Hondt Stéphane Ducasse ESUG 2005 Brussels Inter-Language Reflection
  • 2. Executive Summary Linguistic Symbiosis Inter-Language Reflection = + Reflection SOUL ↭ Smalltalk Agora ↭ Java 2
  • 3. Meta-Programming: A Review Programming Tools ▾ Meta Programming = “Programs about programs” 3
  • 4. Different Base and Meta Languages Meta Program TyRuBa Base Program Java 4
  • 5. No Causal Connection class(Leaf, Node). class(Branch, Node). class Leaf extends Node { class(Visitor, Object). void accept(Visitor v) { method(Leaf,accept, ...). v.visitLeaf(this); method(Node,visitLeaf, ...). } ... } doubleDispatch(Class,Method) :- class Visitor { ... void visitLeaf(Leaf l); visitor(Class) :- void visitBranch(Branch b); ... } 5
  • 6. Reflection MyOwnClass class>>compile: ... MyOwnClass class>>selectors ... MyOwnClass>>makeNewMethod: unarySelector MyOwnClass compile: unarySelector asString ^ MyOwnClass selectors size 6
  • 7. Introducing Inter-Language Reflection Multi-Paradigm Meta Programming Reflection Different Languages Single Language No Causal Connection Causal Connection TyRuBa ↭ Java Smalltalk Inter-Language Reflection Different Languages Causal Connection 7
  • 8. SOUL MyOwnClass class(?c) if var(?c), member(?c, [ Class allInstances ]). class(?c) if nonvar(?c) [ ?c isKindOf: Class ] sends(?c, ?rec, ?sends) if class(?c), method(?c, ?m), sendsTo(?m, ?rec, ?sends). generateEmptyMethod(?class, ?name) if emptyMethodSource(?name, ?source), [(?class compile: ?source) = nil] 8
  • 9. Understanding Inter-Language Reflection? Implementation SOUL Agora RBCL Smalltalk Java C++ Conceptual Model = SOUL Smalltalk Data Mapping ↻ ↻ ▾ Protocol Mapping ??? 9
  • 10. Data Mapping in Agora: Example frame VARIABLE: ("java.awt.Frame" JAVA) new; ok VARIABLE: ("java.awt.Button" JAVA) newString: "OK"; frame addComponent: ok; okListener VARIABLE: [ implements METHOD: (1 ARRAY: ("java.awt.event.ActionListener" JAVA)); replaces METHOD: ("java.lang.Object" JAVA); actionPerformedActionEvent: e METHOD: { ("java.lang.System" JAVA) out printlnString: "Button Pressed!"; frame setVisibleboolean: false } ]; ok addActionListenerActionListener: okListener 10
  • 11. Data Mapping in SOUL business rules if customer is loyal then customer has 10% discount cross-language method / rule customer is loyal if customer has charge card triggering cross-language value exchange customer product business objects 11
  • 12. Data Mapping in SOUL discount(?customer, ?product, 10) if loyal(?customer). discount(?customer, ?product, 15) if student(?customer), Product>>priceFor: aCustomer educationalProduct(?product). | discounts | loyal(?customer) if discounts := [ ?customer hasChargeCard ]. (SOULEvaluator evaluate: 'discount(?customer, ?product, ?discount)' educationalProduct(?product) if withArguments: equals(?sectionitems, [ Section education products ]), (Array with: #customer -> aCustomer [ ?sectionitems includes: ?product ] with: #product -> self)) valuesForVariable: #discount. ^ price * (100 - discounts max) / 100 12
  • 13. Protocol Mappings Language A Language B right left right left Common Implementation Language 13
  • 14. Agora ↭ Java actionPerformedActionEvent: actionPerformed send(“messageType1Name:...TypenName:”, send(“message”, ⇕ {right[arg1], ... right[argn]}) {type1, ... typen}, {arg1, ... argn}) == == result left[result] left[right[x]] = x 14
  • 15. SOUL ↭ Smalltalk ⇕ lo1 unify: lo2 right[lo1] send: #= withArguments: { right[lo2] } 15
  • 16. Implementation Mapping Language A Language B 16
  • 17. Implementation Protocol Mapping receiver.name(argument1, … argumentn) == right[result] left[receiver].send("nameType1Name:…typenName", {left[argument1], …left[argumentn]}) == result 17
  • 18. Conclusion Multi-Paradigm Meta Programming Inter-Language Reflection Different Languages Reflection Causal Connection = Reflection + Linguistic Symbiosis Data Mapping ▾ Protocol Mapping 18