2004 Esug Prototalk

67 %
33 %
Information about 2004 Esug Prototalk

Published on November 15, 2007

Author: bergel

Source: slideshare.net


With prototype-based languages, concretization and abstraction are unified into a single concept a prototype. Prototype-based languages are based on a simple set of principles: object-centered representation, dynamic reshape of objects, cloning and possibly message delegation. However, they all differ in the interpretation and combination of these principles. Therefore there is a need to compare and understand. In this paper we present Prototalk, a research and teaching vehicle to understand, implement and compare prototype-based languages. Prototalk is a framework that offers a predefined set of language data structures and mechanisms that can be composed and extended to generate various prototype-based language interpreters. It presents a classification of languages based on different mechanisms in an operational manner.

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 1

Outline 1. Prototype OO Languages 2. Expressing Different Languages 3. Prototalk 4. Example: Newtonscript 5. Conclusion 2

Prototype OO Languages • Classless paradigm • A prototype contains its state and behavior • Link between prototypes is usually done using: • Delegation • Composition 3

Different Languages • Self: Unification of variables and methods and multiple parents • ObjectLisp: variables distinct from methods • NewtonScript: two kinds of delegation over two links 4

Prototalk 5

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 6

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 7

Architecture MethodNode Prototalk Base selector block AbstractObjectModel eval: context applyWith: args in: context evaluate: sourceCode compileMethodAt: name NodeBuilder compile: codeSource ProgramNode globalVar: varName put: aValue newVariableName: name eval: context nodeBuilder newMessageReceiver: rcvr ... MessageNode VariableNode selector variableName eval: context eval: context Language1 Language1 Language1NodeBuilder variables MessageNode methods newVariableName: name methodOwner: name eval: context newMessageReceiver: clone ... ... Language1 VariableNode eval: context Implementation of Language1 8

Language1 • Language1 is a subclass of AbstractProto • Ability to execute programs • Prototypes are represented by its instances • Provides primitives like clone, addVar: addMethod:, hasVar:, ... 9

Example: NewtonScript _parent _proto • It has a double inheritance: _proto is searched prior to _parent 10

Double Inheritance f := {getX: funct() x, _proto: {_proto: {x: 10}}}; f._parent := {x: 20}; x: 20 f getX x: 10 _parent f.getX() ==> 10 _proto 11

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.’ 12

In Prototalk t := self methodOwnerInProto: name. ^ t isNil AbstractProto ifTrue: [ parent isNil ifTrue: [nil] ifFalse: [parent methodOwner: name]] ifFalse: [t]] NewtonScriptLike parent proto ^ (slots includesKey: name) slots ifTrue: [self] ifFalse: [ methodOwner: name proto isNil methodOwnerInProto: name ifTrue: [nil] ifFalse: [proto methodOwnerInProto: name]] 13

Conclusion • Platform to design and experiment prototypes-based OO language • Pure interpretation of programs • Pedagogical tool: used at University Paris VI, Montpellier and Berne 14

• Prototalk: an Environment for Teaching, Understanding, Designing and Prototyping OO languages • bergel@iam.unibe.ch 15


Hierarchy of Object Model AbstractProto newEmpty SlotProto slots clone addSlot: name ModifiableSlot method: code methodNamed: name L11 L7 initInitials: slots newInitials: slots L7AndImplicitDelegation L7AndExplicitDelegation parent L11AndImplicitDelegation initializeParent: parent parent close clone methodLookup: name parent son SelfLike addSlot: slot L16 assignmentMethod: code 17

ProgramNodeBuilder Smalltalk ProgramNodeBuilder ProgramNodeBuilder newCondition(cond, then, else) AbstractProto newLiteralValue(literal) newMessageReceiver(object) nodeBuilder newMethodSelector(methName) newVariable(varName) newAssignmentVariable(name) ExplicitDelegationPNB ImplicitDelegationPNB EncapsulationPNB SelfLikeAssignment newMessageReceiver: object newMessageReceiver: object newVariable: varName MethodBuilder newAssignmentVariable: name ImplicitDelegation SelfLikePNB EncapsulationPNB ExplicitDelegationEncapsulationPNB newVariable: varName newMessageReceiver: object newVariable: varName newAssignmentVariable: name newAssignmentVariable: name ObjectLispLikePNB newMessageReceiver: object Prototalk ProgramNodeBuilder 18

Self, ObjectLisp, ... Person Person age=26 age=26 name=Luc name=Luc eat(...) eat=... Student Student num=1234567 num=1234567 grade=2 grade=2 doExam(...) doExam=... 19

Add a comment

Related presentations

Related pages

ESUG 2004 Research Track

ESUG 2004 Research Track Editor: St´ephane Ducasse published as Technical Report ... 6 Prototalk: anEnvironmentforTeaching, UnderstandingandPrototypingObject-
Read more

Prototalk : an Environment for Teaching, Understanding ...

Prototalk : an Environment for Teaching, ... ESUG Conference 2004 Research Track (www.esug.org) Objects + message sending + shallowClone handling of
Read more

CiteSeerX — Prototalk: an environment for teaching ...

Prototalk: an environment for teaching, understanding, designing and prototyping object-oriented languages (2004)
Read more

[inria-00533452, v1] Prototalk: an Environment for ...

Prototalk : an Environment for Teaching, Understanding, ... ESUG Conference 2004 Research Track (www.esug.org) inria-00533452, version 1 - 6 Nov 2010
Read more

Classification of object-centered languages (1998) - CiteSeerX

Classification of object-centered languages ... Stéphane Ducasse - In Pro of ESUG International ... In this paper we present Prototalk, ...
Read more

Prototalk: an Environment for Teaching, Understanding ...

Official Full-Text Publication: Prototalk: an Environment for Teaching, Understanding, Designing and Prototyping Object-Oriented Languages on ResearchGate ...
Read more