wyvern: a simple, typed, and pure object-oriented language

58
Wyvern: A Simple, Typed, and Pure Object-Oriented Language Ligia Nistor, Darya Kurilova , Stephanie Balzer, Benjamin Chung, Alex Potanin, and Jonathan Aldrich Carnegie Mellon University © Darya Kurilova 2013 [MASPEGHI‘13, Montpellier, France] 1

Upload: lehanh

Post on 23-Dec-2016

223 views

Category:

Documents


2 download

TRANSCRIPT

Page 1: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Ligia Nistor, Darya Kurilova, Stephanie Balzer, Benjamin Chung, Alex Potanin, and Jonathan Aldrich

Carnegie Mellon University

© Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

1

Page 2: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

World Wide Web •  Cross-­‐Site  Scrip-ng  (XSS)  •  Cross-­‐Site  Request  

Forgery  (CSRF)  •  Injec-on  A;acks  •  Insecure  Direct  Object  

References  •  Broken  Authen-ca-on  

and  Session  Management  •  …            (OWASP  2013)  

•  JavaScript  •  Ruby  on  Rails  •  Java  •  Flash  •  PHP  •  Python  •  CoffeeScript  •  …  

2 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 3: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

World Wide Web

A web and mobile programming language that is

secure by default.

3 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 4: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Wyvern  •  Programming language:

–  For mobile and web programming

–  Secure by default

4 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 5: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Target Characteristics  Web programming Security

•  Pure object-oriented •  Interactive, value-

based •  Supporting functional

programming •  High-level •  Static typing •  Simple

5 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 6: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Target Characteristics  Web programming Security

•  Pure object-oriented •  Interactive, value-

based •  Supporting functional

programming •  High-level •  Static typing •  Simple

6 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 7: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Requirements for Pure OO •  State encapsulation •  Uniform access principle (Meyer) •  Interoperability and uniform treatment

(Cook)

7 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 8: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Current State What Is There:

•  Specialization and generalization of types

•  A pure object-oriented model that supports reuse via composition mechanisms

What Is Missing:

•  A reuse mechanism, such as inheritance or delegation

•  A first-class, typed module system

•  Support for abstract type members

8 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 9: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Next 1.  Wyvern Object Model 2.  Translating Classes to Objects 3.  Discussion: Reuse Mechanism for Wyvern

9 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 10: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Next 1.  Wyvern Object Model 2.  Translating Classes to Objects 3.  Discussion: Reuse Mechanism for Wyvern

10 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 11: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Object-Oriented Core of Wyvern 1   type Lot =

11 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 12: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Object-Oriented Core of Wyvern 1   type Lot = 2   meth value : Int

12 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 13: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Object-Oriented Core of Wyvern 1   type Lot = 2   meth value : Int 3   4   meth purchase(q : Int, p : Int) : Lot = 5   new

13 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 14: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Object-Oriented Core of Wyvern 1   type Lot = 2   meth value : Int 3   4   meth purchase(q : Int, p : Int) : Lot = 5   new 6   var quantity : Int = q 7   var price : Int = p

14 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 15: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Object-Oriented Core of Wyvern 1   type Lot = 2   meth value : Int 3   4   meth purchase(q : Int, p : Int) : Lot = 5   new 6   var quantity : Int = q 7   var price : Int = p 8   meth value : Int = 9   this.quantity * this.price

15 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 16: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Object-Oriented Core of Wyvern 1   type Lot = 2   meth value : Int 3   4   meth purchase(q : Int, p : Int) : Lot = 5   new 6   var quantity : Int = q 7   var price : Int = p 8   meth value : Int = 9   this.quantity * this.price 10   11   val aLot = purchase(100, 100) 12   val value = aLot.value

16 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 17: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Object-Oriented Core of Wyvern 1   type Lot = 2   meth value : Int 3   4   meth purchase(q : Int, p : Int) : Lot = 5   new 6   var quantity : Int = q 7   var price : Int = p 8   meth value : Int = 9   this.quantity * this.price 10   11   val aLot = purchase(100, 100) 12   val value = aLot.value

17 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 18: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Syntax of Object Oriented Core of Wyvern

•  Simple •  Support for functional

programming

18 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 19: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Syntax of Object Oriented Core of Wyvern

19 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 20: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Syntax of Object Oriented Core of Wyvern

20 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 21: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Syntax of Object Oriented Core of Wyvern  

•  State encapsulation •  Uniform access principle •  High-level •  Pure OO

21 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 22: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Next 1.  Wyvern Object Model 2.  Translating Classes to Objects 3.  Discussion: Reuse Mechanism for Wyvern

22 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 23: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Classes Are Not Essential

Cf. Self and JavaScript

…but they are convenient.

We believe classes should be syntactic sugar on top of a foundational object-oriented core.

23 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 24: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Syntax of Object Oriented Core of Wyvern with Classes

24 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 25: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Syntax of Object Oriented Core of Wyvern with Classes

25 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 26: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Syntax of Object Oriented Core of Wyvern with Classes

26 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 27: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Syntax of Object Oriented Core of Wyvern with Classes

27 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 28: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Translating from

28 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 29: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Translating to

29 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 30: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Translating Classes

1   class Option

OO Wyvern with Classes

30 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 31: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Translating Classes

1   class Option 2   var quantity : Int = 0 3   var price : Int = 0

OO Wyvern with Classes

31 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 32: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Translating Classes

1   class Option 2   var quantity : Int = 0 3   var price : Int = 0 4   meth exercise : Int = ...

OO Wyvern with Classes

32 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 33: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Translating Classes

1   class Option 2   var quantity : Int = 0 3   var price : Int = 0 4   meth exercise : Int = ... 5   6   class var totalQuantityIssued : Int = 0

OO Wyvern with Classes

33 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 34: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Translating Classes

1   class Option 2   var quantity : Int = 0 3   var price : Int = 0 4   meth exercise : Int = ... 5   6   class var totalQuantityIssued : Int = 0 7   class meth issue(q : Int, 8   p : Int) : Option = 9   new

OO Wyvern with Classes

34 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 35: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Translating Classes

1   class Option 2   var quantity : Int = 0 3   var price : Int = 0 4   meth exercise : Int = ... 5   6   class var totalQuantityIssued : Int = 0 7   class meth issue(q : Int, 8   p : Int) : Option = 9   new 10   var quantity : Int = q 11   var price : Int = p

OO Wyvern with Classes

35 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 36: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Translating Classes

1   class Option 2   var quantity : Int = 0 3   var price : Int = 0 4   meth exercise : Int = ... 5   6   class var totalQuantityIssued : Int = 0 7   class meth issue(q : Int, 8   p : Int) : Option = 9   new 10   var quantity : Int = q 11   var price : Int = p 12   13   var optn : Option = Option.issue(100, 50) 14   var ret : Int = optn.exercise

OO Wyvern with Classes

36 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 37: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Translating Classes

1   class Option 2   var quantity : Int = 0 3   var price : Int = 0 4   meth exercise : Int = ... 5   6   class var totalQuantityIssued : Int = 0 7   class meth issue(q : Int, 8   p : Int) : Option = 9   new 10   var quantity : Int = q 11   var price : Int = p 12   13   var optn : Option = Option.issue(100, 50) 14   var ret : Int = optn.exercise

OO Wyvern with Classes

37 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 38: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Translating Classes

1   class Option 2   var quantity : Int = 0 3   var price : Int = 0 4   meth exercise : Int = ... 5   6   class var totalQuantityIssued : Int = 0 7   class meth issue(q : Int, 8   p : Int) : Option = 9   new 10   var quantity : Int = q 11   var price : Int = p 12   13   var optn : Option = Option.issue(100, 50) 14   var ret : Int = optn.exercise

OO Wyvern with Classes

38 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 39: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Translating Classes

1   class Option 2   var quantity : Int = 0 3   var price : Int = 0 4   meth exercise : Int = ... 5   6   class var totalQuantityIssued : Int = 0 7   class meth issue(q : Int, 8   p : Int) : Option = 9   new 10   var quantity : Int = q 11   var price : Int = p 12   13   var optn : Option = Option.issue(100, 50) 14   var ret : Int = optn.exercise  

OO Wyvern OO Wyvern with Classes

39 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 40: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Translating Classes

1   class Option 2   var quantity : Int = 0 3   var price : Int = 0 4   meth exercise : Int = ... 5   6   class var totalQuantityIssued : Int = 0 7   class meth issue(q : Int, 8   p : Int) : Option = 9   new 10   var quantity : Int = q 11   var price : Int = p 12   13   var optn : Option = Option.issue(100, 50) 14   var ret : Int = optn.exercise  

1   type Option = 2   meth exercise : Int

OO Wyvern OO Wyvern with Classes

40 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 41: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Translating Classes

1   class Option 2   var quantity : Int = 0 3   var price : Int = 0 4   meth exercise : Int = ... 5   6   class var totalQuantityIssued : Int = 0 7   class meth issue(q : Int, 8   p : Int) : Option = 9   new 10   var quantity : Int = q 11   var price : Int = p 12   13   var optn : Option = Option.issue(100, 50) 14   var ret : Int = optn.exercise  

1   type Option = 2   meth exercise : Int 3   4   type OptionClass = 5   meth issue : Int -> Int -> Option

OO Wyvern OO Wyvern with Classes

41 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 42: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Translating Classes

1   class Option 2   var quantity : Int = 0 3   var price : Int = 0 4   meth exercise : Int = ... 5   6   class var totalQuantityIssued : Int = 0 7   class meth issue(q : Int, 8   p : Int) : Option = 9   new 10   var quantity : Int = q 11   var price : Int = p 12   13   var optn : Option = Option.issue(100, 50) 14   var ret : Int = optn.exercise  

1   type Option = 2   meth exercise : Int 3   4   type OptionClass = 5   meth issue : Int -> Int -> Option 6   7   var Option : OptionClass = 8   new

OO Wyvern OO Wyvern with Classes

42 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 43: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Translating Classes

1   class Option 2   var quantity : Int = 0 3   var price : Int = 0 4   meth exercise : Int = ... 5   6   class var totalQuantityIssued : Int = 0 7   class meth issue(q : Int, 8   p : Int) : Option = 9   new 10   var quantity : Int = q 11   var price : Int = p 12   13   var optn : Option = Option.issue(100, 50) 14   var ret : Int = optn.exercise  

1   type Option = 2   meth exercise : Int 3   4   type OptionClass = 5   meth issue : Int -> Int -> Option 6   7   var Option : OptionClass = 8   new 9   var totalQuantityIssued : Int = 0

OO Wyvern OO Wyvern with Classes

43 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 44: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Translating Classes

1   class Option 2   var quantity : Int = 0 3   var price : Int = 0 4   meth exercise : Int = ... 5   6   class var totalQuantityIssued : Int = 0 7   class meth issue(q : Int, 8   p : Int) : Option = 9   new 10   var quantity : Int = q 11   var price : Int = p 12   13   var optn : Option = Option.issue(100, 50) 14   var ret : Int = optn.exercise  

1   type Option = 2   meth exercise : Int 3   4   type OptionClass = 5   meth issue : Int -> Int -> Option 6   7   var Option : OptionClass = 8   new 9   var totalQuantityIssued : Int = 0 10   meth issue(q : Int, 11   p : Int) : Option = 12   new

OO Wyvern OO Wyvern with Classes

44 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 45: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Translating Classes

1   class Option 2   var quantity : Int = 0 3   var price : Int = 0 4   meth exercise : Int = ... 5   6   class var totalQuantityIssued : Int = 0 7   class meth issue(q : Int, 8   p : Int) : Option = 9   new 10   var quantity : Int = q 11   var price : Int = p 12   13   var optn : Option = Option.issue(100, 50) 14   var ret : Int = optn.exercise  

1   type Option = 2   meth exercise : Int 3   4   type OptionClass = 5   meth issue : Int -> Int -> Option 6   7   var Option : OptionClass = 8   new 9   var totalQuantityIssued : Int = 0 10   meth issue(q : Int, 11   p : Int) : Option = 12   new 13   var quantity : Int = q 14   var price : Int = p

OO Wyvern OO Wyvern with Classes

45 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 46: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Translating Classes

1   class Option 2   var quantity : Int = 0 3   var price : Int = 0 4   meth exercise : Int = ... 5   6   class var totalQuantityIssued : Int = 0 7   class meth issue(q : Int, 8   p : Int) : Option = 9   new 10   var quantity : Int = q 11   var price : Int = p 12   13   var optn : Option = Option.issue(100, 50) 14   var ret : Int = optn.exercise  

1   type Option = 2   meth exercise : Int 3   4   type OptionClass = 5   meth issue : Int -> Int -> Option 6   7   var Option : OptionClass = 8   new 9   var totalQuantityIssued : Int = 0 10   meth issue(q : Int, 11   p : Int) : Option = 12   new 13   var quantity : Int = q 14   var price : Int = p 15   meth exercise : Int = ...

OO Wyvern OO Wyvern with Classes

46 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 47: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Translating Classes

1   class Option 2   var quantity : Int = 0 3   var price : Int = 0 4   meth exercise : Int = ... 5   6   class var totalQuantityIssued : Int = 0 7   class meth issue(q : Int, 8   p : Int) : Option = 9   new 10   var quantity : Int = q 11   var price : Int = p 12   13   var optn : Option = Option.issue(100, 50) 14   var ret : Int = optn.exercise  

1   type Option = 2   meth exercise : Int 3   4   type OptionClass = 5   meth issue : Int -> Int -> Option 6   7   var Option : OptionClass = 8   new 9   var totalQuantityIssued : Int = 0 10   meth issue(q : Int, 11   p : Int) : Option = 12   new 13   var quantity : Int = q 14   var price : Int = p 15   meth exercise : Int = ... 16   17   var optn : Option = Option.issue(100, 50) 18   var ret : Int = optn.exercise  

OO Wyvern OO Wyvern with Classes

47 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 48: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Translating Classes

1   class Option 2   var quantity : Int = 0 3   var price : Int = 0 4   meth exercise : Int = ... 5   6   class var totalQuantityIssued : Int = 0 7   class meth issue(q : Int, 8   p : Int) : Option = 9   new 10   var quantity : Int = q 11   var price : Int = p 12   13   var optn : Option = Option.issue(100, 50) 14   var ret : Int = optn.exercise  

1   type Option = 2   meth exercise : Int 3   4   type OptionClass = 5   meth issue : Int -> Int -> Option 6   7   var Option : OptionClass = 8   new 9   var totalQuantityIssued : Int = 0 10   meth issue(q : Int, 11   p : Int) : Option = 12   new 13   var quantity : Int = q 14   var price : Int = p 15   meth exercise : Int = ... 16   17   var optn : Option = Option.issue(100, 50) 18   var ret : Int = optn.exercise  

OO Wyvern OO Wyvern with Classes

48 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 49: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Next 1.  Wyvern Object Model 2.  Translating Classes to Objects 3.  Discussion: Reuse Mechanism for Wyvern

49 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 50: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Discussion: Reuse Mechanism for Wyvern  

Inheritance vs. Delegation

•  Inheritance is more suitable for classes, but they are not essential.

•  Is delegation more appropriate? •  Inheritance implemented via delegation?

50 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 51: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

A Delegation Scenario Object A: •  has method c() that has a reference to this

Object B: •  delegates to object A •  doesn’t have method c() •  calls method c()

What object should this in method c() refer to? •  e.g., in Self, this refers to object B •  if refers to object B, open recursion

51 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 52: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Auxiliary Slides

52 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 53: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Interoperability and Uniform Treatment

1   type Lot = 2   meth value : Int 3   meth compare(other : Lot) : Int

53 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 54: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Interoperability and Uniform Treatment

4   meth purchase1(q : Int, 5   p : Int) : Lot = 6   new 7   var quantity : Int = q 8   var price : Int = p 9   meth value : Int = ... 10   meth compare(l : Lot) : Int = 11   this.value – l.value

4   meth purchase2(q : Int, 5   p : Int) : Lot = 6   new 7   var quantity : Int = q + 10 8   var price : Int = p 9   meth value : Int = ... 10   meth compare(l : Lot) : Int = 11   this.value – l.value  

1   type Lot = 2   meth value : Int 3   meth compare(other : Lot) : Int

54 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 55: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Interoperability and Uniform Treatment

4   meth purchase1(q : Int, 5   p : Int) : Lot = 6   new 7   var quantity : Int = q 8   var price : Int = p 9   meth value : Int = ... 10   meth compare(l : Lot) : Int = 11   this.value – l.value

4   meth purchase2(q : Int, 5   p : Int) : Lot = 6   new 7   var quantity : Int = q + 10 8   var price : Int = p 9   meth value : Int = ... 10   meth compare(l : Lot) : Int = 11   this.value – l.value  

1   type Lot = 2   meth value : Int 3   meth compare(other : Lot) : Int

55 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 56: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Interoperability and Uniform Treatment

4   meth purchase1(q : Int, 5   p : Int) : Lot = 6   new 7   var quantity : Int = q 8   var price : Int = p 9   meth value : Int = ... 10   meth compare(l : Lot) : Int = 11   this.value – l.value

4   meth purchase2(q : Int, 5   p : Int) : Lot = 6   new 7   var quantity : Int = q + 10 8   var price : Int = p 9   meth value : Int = ... 10   meth compare(l : Lot) : Int = 11   this.value – l.value  

1   type Lot = 2   meth value : Int 3   meth compare(other : Lot) : Int

12   val lot1 = purchase1(70, 50) 13   val lot2 = purchase2(40, 80) 14   val diff = lot1.compare(lot2)

56 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 57: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Full Syntax of Object Oriented Core of Wyvern  

57 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]

Page 58: Wyvern: A Simple, Typed, and Pure Object-Oriented Language

Full Syntax of Object Oriented Core of Wyvern with Classes  

58 © Darya Kurilova 2013

[MASPEGHI‘13, Montpellier, France]