Prototalk

672 views

Published on

Prototalk: an Environment for Teaching, Understanding, Designing and Prototyping OO Languages. Alexandre Bergel, Christophe Dony, Stéphane Ducasse (ESUG 2004, Koethen)

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
672
On SlideShare
0
From Embeds
0
Number of Embeds
4
Actions
Shares
0
Downloads
2
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Prototalk

  1. 1. 1 Prototalk: an Environment for Teaching, Understanding, Designing and Prototyping OO Languages Alexandre Bergel, Christophe Dony, Stéphane Ducasse University of Bern (Switzerland) LIRMM, Montpellier (France) bergel@iam.unibe.ch
  2. 2. 2 Outline 1. Prototype OO Languages 2. Expressing Different Languages 3. Prototalk 4. Example: Newtonscript 5. Conclusion
  3. 3. 3 Prototype OO Languages • Classless paradigm • A prototype contains its state and behavior • Link between prototypes is usually done using: • Delegation • Composition
  4. 4. 4 Different Languages • Self: Unification of variables and methods and multiple parents • ObjectLisp: variables distinct from methods • NewtonScript: two kinds of delegation over two links
  5. 5. 5 Prototalk
  6. 6. 6 Goal and Design Decisions • Uniformity: same syntax for all the languages • Minimality: minimal kernel to express the most general semantics • Extensibility: new languages has to be implemented efficiently and easily • Usability: integrated in the environment
  7. 7. 7 Prototalk • Language represented by a subclass of AbstractProto • Execution of program by sending evaluate: to it • The AST is built using a ProgramNodeBuilder • It is composed of subclass of the Smalltalk AST nodes
  8. 8. 8 Architecture AbstractObjectModel evaluate: sourceCode compileMethodAt: name compile: codeSource globalVar: varName put: aValue nodeBuilder NodeBuilder newVariableName: name newMessageReceiver: rcvr ... ProgramNode eval: context MethodNode selector block eval: context applyWith: args in: context VariableNode variableName eval: context MessageNode selector eval: context Language1 variables methods methodOwner: name clone ... Language1NodeBuilder newVariableName: name newMessageReceiver: ... Language1 VariableNode eval: context Language1 MessageNode eval: context Prototalk Base Implementation of Language1
  9. 9. 9 Language1 • Language1 is a subclass of AbstractProto • Ability to execute programs • Prototypes are represented by its instances • Provides primitives like clone, addVar: addMethod:, hasVar:, ...
  10. 10. 10 Example: NewtonScript • It has a double inheritance: _proto is searched prior to _parent _parent _proto
  11. 11. 11 Double Inheritance f := {getX: funct() x, _proto: {_proto: {x: 10}}}; f._parent := {x: 20}; f getX x: 10 x: 20 _parent _proto f.getX() ==> 10
  12. 12. 12 In Prototalk f := {getX: funct() x, _proto: {_proto: {x: 10}}}; f._parent := {x: 20}; f.getX() ==> 10 The same program in Prototalk: NewtonScriptLike evaluate: ‘ f := PRoot clone. f proto: (PRoot clone; proto: (PRoot clone; addSlot: ‘‘x = 10’’)). f addSlot: ‘‘getX x’’. f parent: (PRoot clone; addSlot: ‘x = 20’). f getX.’
  13. 13. 13 In Prototalk AbstractProto NewtonScriptLike parent proto methodOwner: name methodOwnerInProto: name t := self methodOwnerInProto: name. ^ t isNil ifTrue: [ parent isNil ifTrue: [nil] ifFalse: [parent methodOwner: name]] ifFalse: [t]] ^ (slots includesKey: name) ifTrue: [self] ifFalse: [ proto isNil ifTrue: [nil] ifFalse: [proto methodOwnerInProto: name]] slots
  14. 14. 14 Conclusion • Platform to design and experiment prototypes-based OO language • Pure interpretation of programs • Pedagogical tool: used at University Paris VI, Montpellier and Berne
  15. 15. 15 • Prototalk: an Environment for Teaching, Understanding, Designing and Prototyping OO languages • bergel@iam.unibe.ch
  16. 16. 16
  17. 17. 17 Hierarchy of Object Model AbstractProto newEmpty SlotProto slots clone addSlot: name method: code methodNamed: name L11 initInitials: slots newInitials: slots L11AndImplicitDelegation parent clone methodLookup: name parent son L16 ModifiableSlot L7 L7AndImplicitDelegation parent initializeParent: parent close SelfLike addSlot: slot assignmentMethod: code L7AndExplicitDelegation
  18. 18. 18 ProgramNodeBuilder SelfLikeAssignment MethodBuilder Smalltalk ProgramNodeBuilder Prototalk ProgramNodeBuilder ProgramNodeBuilder newCondition(cond, then, else) newLiteralValue(literal) newMessageReceiver(object) newMethodSelector(methName) newVariable(varName) newAssignmentVariable(name) ImplicitDelegationPNB newMessageReceiver: object ImplicitDelegation EncapsulationPNB newMessageReceiver: object newAssignmentVariable: name ObjectLispLikePNB newMessageReceiver: object SelfLikePNB newVariable: varName EncapsulationPNB newVariable: varName newAssignmentVariable: name ExplicitDelegationPNB newMessageReceiver: object ExplicitDelegationEncapsulationPNB newVariable: varName newAssignmentVariable: name AbstractProto nodeBuilder
  19. 19. 19 Self, ObjectLisp, ... Person age=26 name=Luc eat=... Student num=1234567 grade=2 doExam=... Person age=26 name=Luc eat(...) Student num=1234567 grade=2 doExam(...)

×