CS 4110 Programming Languages & Logics. Lecture 30 Featherweight Java and Object Encodings

Size: px
Start display at page:

Download "CS 4110 Programming Languages & Logics. Lecture 30 Featherweight Java and Object Encodings"

Transcription

1 CS 4110 Programming Languages & Logics Lecture 30 Featherweight Java and Object Encodings 11 November 2016

2 Properties 2 Lemma (Preservation) If Γ e : C and e e then there exists a type C such that Γ e : C and C C. Lemma (Progress) Let e be an expression such that e : C. Then either: 1. e is a value, 2. there exists an expression e such that e e, or 3. e = E[(B) (new A(v))] with A B.

3 Lemmas 3 Lemma (Method Typing) If mtype(m, C) = D D and mbody(m, C) = (x, e) then there exists types C and D such that x : D, this : C e : D and D D.

4 Lemmas 3 Lemma (Method Typing) If mtype(m, C) = D D and mbody(m, C) = (x, e) then there exists types C and D such that x : D, this : C e : D and D D. Lemma (Substitution) If Γ, x : B e : C and Γ u : B with B B then there exists C such that Γ [x u]e : C and C C.

5 Lemmas 3 Lemma (Method Typing) If mtype(m, C) = D D and mbody(m, C) = (x, e) then there exists types C and D such that x : D, this : C e : D and D D. Lemma (Substitution) If Γ, x : B e : C and Γ u : B with B B then there exists C such that Γ [x u]e : C and C C. Lemma (Weakening) If Γ e : C then Γ, x : B e : C.

6 Lemmas 4 Lemma (Decomposition) If Γ E[e] : C then there exists a type B such that Γ e : B

7 Lemmas 4 Lemma (Decomposition) If Γ E[e] : C then there exists a type B such that Γ e : B Lemma (Context) If Γ E[e] : C and Γ e : B and Γ e : B with B B then there exists a type C such that Γ E[e ] : C and C C.

8 Operational Semantics (D) new C(v) new C(v) E-CAST 5 E ::= [ ] E.f E.m(e) v.m(v, E, e) new C(v, E, e) (C) E e e E[e] E[e ] E-CONTEXT fields(c) = C f new C(v).f i v i E-PROJ mbody(m, C) = (x, e) new C(v).m(u) [x u, this new C(v)]e E-INVK C D

9 Lemmas 6 Lemma (Canonical Forms) If v : C then v = new C(v). Lemma (Inversion) 1. If (new C(v)).f i : C i then fields(c) = C f and f i f. 2. If (new C(v)).m(u) : C then mbody(m, C) = (x, e) and u = e.

10 Typing Rules 7 Γ(x) = C Γ x : C T-VAR Γ e : C fields(c) = C f T-FIELD Γ e.f i : C i Γ e : C mtype(m, C) = B B Γ e : A A B T-INVK Γ e.m(e) : B fields(c) = C f Γ e : B B C T-NEW Γ new C(e) : C Γ e : D D C T-UCAST Γ (C) e : C Γ e : D C D C D T-DCAST Γ (C) e : C Γ e : D C D D C stupid warning T-SCAST Γ (C) e : C

11 Object Encodings

12 Object-Oriented Features 9 Dynamic dispatch Encapsulation Subtyping Inheritance Open recursion

13 Record Encoding 10 type pointrep = { x:int ref; y:int ref }

14 Record Encoding 10 type pointrep = { x:int ref; y:int ref } type point = { movex:int -> unit; movey:int -> unit }

15 Record Encoding 10 type pointrep = { x:int ref; y:int ref } type point = { movex:int -> unit; movey:int -> unit } let pointclass : pointrep -> point = (fun (r:pointrep) -> { movex = (fun d -> r.x :=!(r.x) + d); movey = (fun d -> r.y :=!(r.x) + d) })

16 Record Encoding 10 type pointrep = { x:int ref; y:int ref } type point = { movex:int -> unit; movey:int -> unit } let pointclass : pointrep -> point = (fun (r:pointrep) -> { movex = (fun d -> r.x :=!(r.x) + d); movey = (fun d -> r.y :=!(r.x) + d) }) let newpoint : int -> int -> point = (fun (x:int) -> (fun (y:int) -> pointclass { x = ref x; y = ref y }))

17 Inheritance 11 type point3drep = { x:int ref; y:int ref; z:int ref } type point3d = { movex:int -> unit; movey:int -> unit; movez:int -> unit }

18 Inheritance 11 type point3drep = { x:int ref; y:int ref; z:int ref } type point3d = { movex:int -> unit; movey:int -> unit; movez:int -> unit } let point3dclass : point3drep -> point3d = (fun (r:point3drep) -> let super = pointclass r in { movex = super.movex; movey = super.movey; movez = (fun d -> r.z :=!(r.x) + d) } )

19 Inheritance 11 type point3drep = { x:int ref; y:int ref; z:int ref } type point3d = { movex:int -> unit; movey:int -> unit; movez:int -> unit } let point3dclass : point3drep -> point3d = (fun (r:point3drep) -> let super = pointclass r in { movex = super.movex; movey = super.movey; movez = (fun d -> r.z :=!(r.x) + d) } ) let newpoint3d : int -> int -> int -> point3d = (fun (x:int) -> (fun (y:int) -> (fun (z:int) -> point3dclass { x = ref x; y = ref y; z = ref z })))

20 Open Recursion With Self 12 type altpointrep = { x:int ref; y:int ref }

21 Open Recursion With Self 12 type altpointrep = { x:int ref; y:int ref } type altpoint = { movex:int -> unit; movey:int -> unit; move: int -> int -> unit }

22 Open Recursion With Self 12 type altpointrep = { x:int ref; y:int ref } type altpoint = { movex:int -> unit; movey:int -> unit; move: int -> int -> unit } let altpointclass : altpointrep -> altpoint ref -> altpoint = (fun (r:altpointrep) -> (fun (self:altpoint ref) -> { movex = (fun d -> r.x :=!(r.x) + d); movey = (fun d -> r.y :=!(r.y) + d); move = (fun dx dy -> (!self.movex) dx; (!self.movey) dy) }))

23 Open Recursion with Self 13 let dummyaltpoint : altpoint = { movex = (fun d -> ()); movey = (fun d -> ()); move = (fun dx dy -> ()) }

24 Open Recursion with Self 13 let dummyaltpoint : altpoint = { movex = (fun d -> ()); movey = (fun d -> ()); move = (fun dx dy -> ()) } let newaltpoint : int -> int -> altpoint = (fun (x:int) -> (fun (y:int) -> let r = { x = ref x; y = ref y } in let cref = ref dummyaltpoint in cref := altpointclass r cref;!cref ))

Software Engineering

Software Engineering Software Engineering Lecture 18: Featherweight Java Peter Thiemann University of Freiburg, Germany 15.07.2013 Peter Thiemann (Univ. Freiburg) Software Engineering 15.07.2013 1 / 41 Contents Featherweight

More information

Softwaretechnik. Lecture 18: Featherweight Java. Peter Thiemann. University of Freiburg, Germany

Softwaretechnik. Lecture 18: Featherweight Java. Peter Thiemann. University of Freiburg, Germany Softwaretechnik Lecture 18: Peter Thiemann University of Freiburg, Germany 19.07.2012 Peter Thiemann (Univ. Freiburg) Softwaretechnik 19.07.2012 1 / 40 Contents The language shown in examples Formal Definition

More information

Contents. Softwaretechnik. Type Safety of Java. Featherweight Java. Lecture 21: Featherweight Java

Contents. Softwaretechnik. Type Safety of Java. Featherweight Java. Lecture 21: Featherweight Java Contents Softwaretechnik Lecture 21: Peter Thiemann Universität Freiburg, Germany Operational Semantics SS 2011 Peter Thiemann (Univ. Freiburg) Softwaretechnik (english draft) SWT 1 / 40 Type Safety of

More information

Featherweight Java (FJ)

Featherweight Java (FJ) x = 1 let x = 1 in... x(1).!x(1) x.set(1) Programming Language Theory Featherweight Java (FJ) Ralf Lämmel This lecture is based on David Walker s lecture: Computer Science 441, Programming Languages, Princeton

More information

Featherweight Java. Lecture 12 CS 565 3/18/08

Featherweight Java. Lecture 12 CS 565 3/18/08 Featherweight Java Lecture 12 CS 565 3/18/08 Objects vs Functions Will start exploring an object model that treats objects and classes as primitives Avoids some of the complexities faced when encoding

More information

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages

Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 14 Tuesday, March 24, 2015 1 Parametric polymorphism Polymorph means many forms. Polymorphism is the ability of

More information

Type-Safe Feature-Oriented Product Lines

Type-Safe Feature-Oriented Product Lines Type-Safe Feature-Oriented Product Lines arxiv:1001.3604v1 [cs.se] 20 Jan 2010 Sven Apel, Christian Kästner, Armin Größlinger, and Christian Lengauer Department of Informatics and Mathematics, University

More information

Inference, Targeting and Compatibility in a Type System for Java with SAM Typed Closures

Inference, Targeting and Compatibility in a Type System for Java with SAM Typed Closures Inference, Targeting and Compatibility in a Type System for Java with SAM Typed Closures Marco Bellia and M. Eugenia Occhiuto Dipartimento di Informatica, Università di Pisa, Italy {bellia,occhiuto}@di.unipi.it

More information

CS 611 Advanced Programming Languages

CS 611 Advanced Programming Languages CS 611 Advanced Programming Languages Andrew Myers Cornell University Lecture 38 Object-oriented languages 26 Nov 07 Object-oriented languages Dominant programming paradigm for foreseeable future. Why?

More information

Type-based Confinement

Type-based Confinement Under consideration for publication in J. Functional Programming 1 Type-based Confinement Tian Zhao University of Wisconsin Milwaukee Jens Palsberg UCLA Jan Vitek Purdue University Abstract Confinement

More information

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011

CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Dan Grossman Spring 2011 CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics Dan Grossman Spring 2011 Review e ::= λx. e x e e c v ::= λx. e c τ ::= int τ τ Γ ::= Γ, x : τ (λx. e) v e[v/x] e 1 e 1 e 1 e

More information

Lecture 13: Subtyping

Lecture 13: Subtyping Lecture 13: Subtyping Polyvios Pratikakis Computer Science Department, University of Crete Type Systems and Programming Languages Pratikakis (CSD) Subtyping CS546, 2018-2019 1 / 15 Subtyping Usually found

More information

Review. CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Let bindings (CBV) Adding Stuff. Booleans and Conditionals

Review. CS152: Programming Languages. Lecture 11 STLC Extensions and Related Topics. Let bindings (CBV) Adding Stuff. Booleans and Conditionals Review CS152: Programming Languages Lecture 11 STLC Extensions and Related Topics e ::= λx. e x ee c v ::= λx. e c (λx. e) v e[v/x] e 1 e 2 e 1 e 2 τ ::= int τ τ Γ ::= Γ,x : τ e 2 e 2 ve 2 ve 2 e[e /x]:

More information

A Co-contextual Type Checker for Featherweight Java (incl. Proofs)

A Co-contextual Type Checker for Featherweight Java (incl. Proofs) A Co-contextual Type Checker for Featherweight Java (incl. Proofs) Edlira Kuci 1, Sebastian Erdweg 2, Oliver Bračevac 1, Andi Bejleri 1, and Mira Mezini 1,3 1 Technische Universität Darmstadt, Germany

More information

Science of Computer Programming

Science of Computer Programming Science of Computer Programming 74 (2009) 261 278 Contents lists available at ScienceDirect Science of Computer Programming journal homepage: www.elsevier.com/locate/scico Featherweight Java with dynamic

More information

ob-ject: to feel distaste for something Webster's Dictionary

ob-ject: to feel distaste for something Webster's Dictionary Objects ob-ject: to feel distaste for something Webster's Dictionary Prof. Clarkson Fall 2017 Today s music: Kung Fu Fighting by CeeLo Green Review Currently in 3110: Advanced topics Futures Monads Today:

More information

Research Reports on Mathematical and Computing Sciences

Research Reports on Mathematical and Computing Sciences ISSN 1342-2812 Research Reports on Mathematical and Computing Sciences Mostly modular composition of crosscutting structures by contextual predicate dispatch (extended version) Shigeru Chiba and Atsushi

More information

Subtyping (cont) Lecture 15 CS 565 4/3/08

Subtyping (cont) Lecture 15 CS 565 4/3/08 Subtyping (cont) Lecture 15 CS 565 4/3/08 Formalization of Subtyping Inversion of the subtype relation: If σ

More information

An Overview of Feature Featherweight Java

An Overview of Feature Featherweight Java An Overview of Feature Featherweight Java Sven Apel, Christian Kästner, and Christian Lengauer Department of Informatics and Mathematics, University of Passau, Germany {apel,lengauer}@uni-passau.de School

More information

Delegation by Object Composition

Delegation by Object Composition Delegation by Object Composition Lorenzo Bettini,a, Viviana Bono a, Betti Venneri b a Dipartimento di Informatica, Università di Torino b Dipartimento di Sistemi e Informatica, Università di Firenze Abstract

More information

Name: Pennkey: CIS 120 Midterm II November 18, 2011

Name: Pennkey: CIS 120 Midterm II November 18, 2011 Name: Pennkey: CIS 120 Midterm II November 18, 2011 1 /20 2 /20 3 /20 4 /20 5 /20 Total /100 Do not begin the exam until you are told to do so. You have 50 minutes to complete the exam. There are 100 total

More information

Featherweight Wrap Java: wrapping objects and methods

Featherweight Wrap Java: wrapping objects and methods Vol. 7, No. 2, Special Issue OOPS Track at SAC 2007, February 2008 Featherweight Wrap Java: wrapping objects and methods Lorenzo Bettini, bettini@dsi.unifi.it Dipartimento di Informatica, Università di

More information

Objects. Prof. Clarkson Fall ob-ject: to feel distaste for something Webster's Dictionary. Today s music: Kung Fu Fighting by CeeLo Green

Objects. Prof. Clarkson Fall ob-ject: to feel distaste for something Webster's Dictionary. Today s music: Kung Fu Fighting by CeeLo Green Objects ob-ject: to feel distaste for something Webster's Dictionary Prof. Clarkson Fall 2016 Today s music: Kung Fu Fighting by CeeLo Green Review Currently in 3110: Advanced topics Futures Monads Proofs

More information

Subtyping (cont) Formalization of Subtyping. Lecture 15 CS 565. Inversion of the subtype relation:

Subtyping (cont) Formalization of Subtyping. Lecture 15 CS 565. Inversion of the subtype relation: Subtyping (cont) Lecture 15 CS 565 Formalization of Subtyping Inversion of the subtype relation:! If "

More information

The Substitution Model

The Substitution Model The Substitution Model Prof. Clarkson Fall 2017 Today s music: Substitute by The Who Review Previously in 3110: simple interpreter for expression language abstract syntax tree (AST) evaluation based on

More information

Subtyping. Lecture 13 CS 565 3/27/06

Subtyping. Lecture 13 CS 565 3/27/06 Subtyping Lecture 13 CS 565 3/27/06 Polymorphism Different varieties of polymorphism: Parametric (ML) type variables are abstract, and used to encode the fact that the same term can be used in many different

More information

Lightweight Confinement for Featherweight Java

Lightweight Confinement for Featherweight Java Lightweight Confinement for Featherweight Java Tian Zhao Jens Palsberg Jan Vitek University of Wisconsin, Milwaukee Purdue University ABSTRACT Confinement properties impose a structure on object graphs

More information

Science of Computer Programming

Science of Computer Programming Science of Computer Programming 76 (2011) 992 1014 Contents lists available at ScienceDirect Science of Computer Programming journal homepage: www.elsevier.com/locate/scico Delegation by object composition

More information

Programming Languages

Programming Languages CSE 230: Winter 2008 Principles of Programming Languages Ocaml/HW #3 Q-A Session Push deadline = Mar 10 Session Mon 3pm? Lecture 15: Type Systems Ranjit Jhala UC San Diego Why Typed Languages? Development

More information

CSE505, Fall 2012, Midterm Examination October 30, 2012

CSE505, Fall 2012, Midterm Examination October 30, 2012 CSE505, Fall 2012, Midterm Examination October 30, 2012 Rules: The exam is closed-book, closed-notes, except for one side of one 8.5x11in piece of paper. Please stop promptly at Noon. You can rip apart

More information

Object-Oriented Programming. Lecture 16 CS 565 4/10/08

Object-Oriented Programming. Lecture 16 CS 565 4/10/08 Object-Oriented Programming Lecture 16 CS 565 4/10/08 Object-Based Programming View basic features found in object-based systems: objects dynamic dispatch encapsulation of state inheritance self-reference

More information

On Subtyping, Wildcards, and Existential Types

On Subtyping, Wildcards, and Existential Types On Subtyping, Wildcards, and Existential Types Nicholas Cameron Victoria University of Wellington ncameron@ecs.vuw.ac.nz Sophia Drossopoulou Imperial College London scd@doc.ic.ac.uk ABSTRACT Wildcards

More information

A Type System for the Relational Calculus of Object Systems

A Type System for the Relational Calculus of Object Systems UNU/IIST International Institute for Software Technology A Type System for the Relational Calculus of Object Systems Liang Zhao, Xiangpeng Zhao, Quan Long and Zongyan Qiu September 2006 UNU-IIST Report

More information

Programmazione. Prof. Marco Bertini

Programmazione. Prof. Marco Bertini Programmazione Prof. Marco Bertini marco.bertini@unifi.it http://www.micc.unifi.it/bertini/ Design patterns Design patterns are bug reports against your programming language. - Peter Norvig What are design

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 21 March 12, 2018 Java: Objects, Interfaces, Static Members Chapters 19 & 20 Announcements Java Bootcamp Tonight!! Towne 100, 6-8 pm HW06: Pennstagram

More information

The Substitution Model. Nate Foster Spring 2018

The Substitution Model. Nate Foster Spring 2018 The Substitution Model Nate Foster Spring 2018 Review Previously in 3110: simple interpreter for expression language abstract syntax tree (AST) evaluation based on single steps parser and lexer (in lab)

More information

Compiler Construction I

Compiler Construction I TECHNISCHE UNIVERSITÄT MÜNCHEN FAKULTÄT FÜR INFORMATIK Compiler Construction I Dr. Michael Petter, Dr. Axel Simon SoSe 2014 1 / 30 Topic: Semantic Analysis 2 / 30 Semantic Analysis Chapter 1: Type Checking

More information

CSE-321 Programming Languages 2010 Final

CSE-321 Programming Languages 2010 Final Name: Hemos ID: CSE-321 Programming Languages 2010 Final Prob 1 Prob 2 Prob 3 Prob 4 Prob 5 Prob 6 Total Score Max 18 28 16 12 36 40 150 There are six problems on 16 pages, including two work sheets, in

More information

On to Objects. CIS 500 Software Foundations Fall November 20. A Change of Pace. Case study: object-oriented programming

On to Objects. CIS 500 Software Foundations Fall November 20. A Change of Pace. Case study: object-oriented programming CIS 500 Software Foundations Fall 2006 On to Objects November 20 A Change of Pace We ve spent the semester developing tools for defining and reasoning about a variety of programming language features.

More information

Object typing and subtypes

Object typing and subtypes CS 242 2012 Object typing and subtypes Reading Chapter 10, section 10.2.3 Chapter 11, sections 11.3.2 and 11.7 Chapter 12, section 12.4 Chapter 13, section 13.3 Subtyping and Inheritance Interface The

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 22 March 14 th, 2016 Object Oriented Programming in Java Java Bootcamp tonight Announcements Monday, March 14 from 6-8pm in Levine 101 (Wu & Chen)

More information

A First Class Approach to Java Genericity

A First Class Approach to Java Genericity A First Class Approach to Java Genericity Eric E. Allen Jonathan Bannet Robert Cartwright eallen@cs.rice.edu jbannet@cs.rice.edu cork@cs.rice.edu Rice University 6100 S. Main St. Houston TX 77005 September

More information

CMSC 330: Organization of Programming Languages. Lets, Tuples, Records

CMSC 330: Organization of Programming Languages. Lets, Tuples, Records CMSC 330: Organization of Programming Languages Lets, Tuples, Records CMSC330 Spring 2018 1 Let Expressions Enable binding variables in other expressions These are different from the let definitions we

More information

CS 4110 Programming Languages & Logics. Lecture 28 Recursive Types

CS 4110 Programming Languages & Logics. Lecture 28 Recursive Types CS 4110 Programming Languages & Logics Lecture 28 Recursive Types 7 November 2014 Announcements 2 Foster office hours 11-12pm Guest lecture by Fran on Monday Recursive Types 3 Many languages support recursive

More information

CS4215 Programming Language Implementation. Martin Henz

CS4215 Programming Language Implementation. Martin Henz CS4215 Programming Language Implementation Martin Henz Thursday 26 January, 2012 2 Chapter 4 The Language simpl In this chapter, we are exting the language epl in order to provide a more powerful programming

More information

CS422 - Programming Language Design

CS422 - Programming Language Design 1 CS422 - Programming Language Design Elements of Object-Oriented Programming Grigore Roşu Department of Computer Science University of Illinois at Urbana-Champaign 2 During this and the next lecture we

More information

Object-Oriented Languages and Object-Oriented Design. Ghezzi&Jazayeri: OO Languages 1

Object-Oriented Languages and Object-Oriented Design. Ghezzi&Jazayeri: OO Languages 1 Object-Oriented Languages and Object-Oriented Design Ghezzi&Jazayeri: OO Languages 1 What is an OO language? In Ada and Modula 2 one can define objects encapsulate a data structure and relevant operations

More information

LazyJ: Seamless Lazy Evaluation in Java

LazyJ: Seamless Lazy Evaluation in Java LazyJ: Seamless Lazy Evaluation in Java Alessandro Warth Computer Science Department University of California, Los Angeles awarth@cs.ucla.edu Abstract LazyJ is a backward-compatible extension of the Java

More information

Overview. Elements of Programming Languages. Objects. Self-Reference

Overview. Elements of Programming Languages. Objects. Self-Reference Overview Elements of Programming Languages Lecture 11: James Cheney University of Edinburgh November 3, 2015 Last time: programming in the large Programs, packages/namespaces, importing Modules and interfaces

More information

Safely Creating Correct Subclasses without Seeing Superclass Code

Safely Creating Correct Subclasses without Seeing Superclass Code Safely Creating Correct Subclasses without Seeing Superclass Code Clyde Ruby and Gary T. Leavens Department of Computer Science Iowa State University 226 Atanasoff Hall, Ames, IA 50011 USA +1 515 294 1580

More information

Subtyping and Objects

Subtyping and Objects Subtyping and Objects Massimo Merro 20 November 2017 Massimo Merro Data and Mutable Store 1 / 22 Polymorphism So far, our type systems are very rigid: there is little support to code reuse. Polymorphism

More information

Type Hierarchy. Lecture 6: OOP, autumn 2003

Type Hierarchy. Lecture 6: OOP, autumn 2003 Type Hierarchy Lecture 6: OOP, autumn 2003 The idea Many types have common behavior => type families share common behavior organized into a hierarchy Most common on the top - supertypes Most specific at

More information

CS 4110 Programming Languages & Logics. Lecture 27 Recursive Types

CS 4110 Programming Languages & Logics. Lecture 27 Recursive Types CS 4110 Programming Languages & Logics Lecture 27 Recursive Types 4 November 2016 Announcements 2 My office hours are at the normal time today but canceled on Monday Guest lecture by Seung Hee Han on Monday

More information

Product Lines of Theorems

Product Lines of Theorems Product Lines of Theorems Benjamin Delaware William R. Cook Don Batory Department of Computer Science University of Texas at Austin {bendy,wcook,batory}@cs.utexas.edu Abstract Mechanized proof assistants

More information

Implicit Ownership Types for Memory Management

Implicit Ownership Types for Memory Management Implicit Ownership Types for Memory Management Tian Zhao a,, Jason Baker b, James Hunt c, James Noble d, Jan Vitek b, a University of Wisconsin Milwaukee, USA b Purdue University, West Lafayette, USA c

More information

Harvard School of Engineering and Applied Sciences Computer Science 152

Harvard School of Engineering and Applied Sciences Computer Science 152 Harvard School of Engineering and Applied Sciences Computer Science 152 Lecture 17 Tuesday, March 30, 2010 1 Polymorph means many forms. Polymorphism is the ability of code to be used on values of different

More information

Outline. Inheritance. Abstract Classes Interfaces. Class Extension Overriding Methods Inheritance and Constructors Polymorphism.

Outline. Inheritance. Abstract Classes Interfaces. Class Extension Overriding Methods Inheritance and Constructors Polymorphism. Outline Inheritance Class Extension Overriding Methods Inheritance and Constructors Polymorphism Abstract Classes Interfaces 1 OOP Principles Encapsulation Methods and data are combined in classes Not

More information

CSE-321 Programming Languages 2012 Midterm

CSE-321 Programming Languages 2012 Midterm Name: Hemos ID: CSE-321 Programming Languages 2012 Midterm Prob 1 Prob 2 Prob 3 Prob 4 Prob 5 Prob 6 Total Score Max 14 15 29 20 7 15 100 There are six problems on 24 pages in this exam. The maximum score

More information

Overview. Elements of Programming Languages. Objects. Self-Reference

Overview. Elements of Programming Languages. Objects. Self-Reference Overview Elements of Programming Languages Lecture 10: James Cheney University of Edinburgh October 23, 2017 Last time: programming in the large Programs, packages/namespaces, importing Modules and interfaces

More information

Safely Creating Correct Subclasses without Seeing Superclass Code

Safely Creating Correct Subclasses without Seeing Superclass Code Safely Creating Correct Subclasses without Seeing Superclass Code Clyde Ruby and Gary T. Leavens TR #00-05d April 2000, revised April, June, July 2000 Keywords: Downcalls, subclass, semantic fragile subclassing

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques (CIS120) Lecture 21 March 6 th, 2015 Transi@on to Java CIS 120 Overview Declara@ve (Func@onal) programming persistent data structures recursion is main control structure

More information

Lifted Java: A Minimal Calculus for Translation Polymorphism

Lifted Java: A Minimal Calculus for Translation Polymorphism Lifted Java: A Minimal Calculus for Translation Polymorphism Matthias Diehn Ingesman and Erik Ernst Department of Computer Science, Aarhus University, Denmark, {mdi,eernst}@cs.au.dk Abstract. To support

More information

CSE 505, Fall 2008, Midterm Examination 29 October Please do not turn the page until everyone is ready.

CSE 505, Fall 2008, Midterm Examination 29 October Please do not turn the page until everyone is ready. CSE 505, Fall 2008, Midterm Examination 29 October 2008 Please do not turn the page until everyone is ready. Rules: The exam is closed-book, closed-note, except for one side of one 8.5x11in piece of paper.

More information

We defined congruence rules that determine the order of evaluation, using the following evaluation

We defined congruence rules that determine the order of evaluation, using the following evaluation CS 4110 Programming Languages and Logics Lectures #21: Advanced Types 1 Overview In this lecture we will extend the simply-typed λ-calculus with several features we saw earlier in the course, including

More information

Exercise 6 Multiple Inheritance, Multiple Dispatch and Linearization November 4, 2016

Exercise 6 Multiple Inheritance, Multiple Dispatch and Linearization November 4, 2016 Concepts of Object-Oriented Programming AS 2016 Exercise 6 Multiple Inheritance, Multiple Dispatch and Linearization November 4, 2016 Task 1 Consider the following C++ program: class X X(int p) : fx(p)

More information

Implicit Ownership Types for Memory Management

Implicit Ownership Types for Memory Management Implicit Ownership Types for Memory Management Tian Zhao 1, Jason Baker 2, James Hunt 3, James Noble 4, and Jan Vitek 2 (1) University of Wisconsin Milwaukee, USA (2) Purdue University, West Lafayette,

More information

Type Safe Dynamic Object Delegation in Class-based Languages

Type Safe Dynamic Object Delegation in Class-based Languages Type Safe Dynamic Object Delegation in Class-based Languages Lorenzo Bettini Viviana Bono Dipartimento di Informatica, Università di Torino Corso Svizzera 185, 10149 Torino - Italy ABSTRACT Class inheritance

More information

CS205: Scalable Software Systems

CS205: Scalable Software Systems CS205: Scalable Software Systems Lecture 4 September 14, 2016 Lecture 4 CS205: Scalable Software Systems September 14, 2016 1 / 16 Quick Recap Things covered so far Problem solving by recursive decomposition

More information

CS131 Typed Lambda Calculus Worksheet Due Thursday, April 19th

CS131 Typed Lambda Calculus Worksheet Due Thursday, April 19th CS131 Typed Lambda Calculus Worksheet Due Thursday, April 19th Name: CAS ID (e.g., abc01234@pomona.edu): I encourage you to collaborate. collaborations below. Please record your Each question is worth

More information

Some instance messages and methods

Some instance messages and methods Some instance messages and methods x ^x y ^y movedx: dx Dy: dy x

More information

Coinductive big-step operational semantics for type soundness of Java-like languages

Coinductive big-step operational semantics for type soundness of Java-like languages Coinductive big-step operational semantics for type soundness of Java-like languages Davide Ancona DISI, University of Genova, Italy davide@disi.unige.it ABSTRACT We define a coinductive semantics for

More information

Software Engineering CSC40232: SOFTWARE ENGINEERING. Guest Lecturer: Jin Guo SOLID Principles sarec.nd.edu/courses/se2017

Software Engineering CSC40232: SOFTWARE ENGINEERING. Guest Lecturer: Jin Guo SOLID Principles sarec.nd.edu/courses/se2017 CSC40232: SOFTWARE ENGINEERING Guest Lecturer: Jin Guo SOLID Principles sarec.nd.edu/courses/se2017 Department of Computer Science and Engineering http://www.kirkk.com/modularity/2009/12/solid-principles-of-class-design/

More information

Mariangiola Dezani-Ciancaglini 1, Paola Giannini 2 and Elena Zucca 3

Mariangiola Dezani-Ciancaglini 1, Paola Giannini 2 and Elena Zucca 3 Theoretical Informatics and Applications Informatique Théorique et Applications Will be set by the publisher EXTENDING THE LAMBDA-CALCULUS WITH UNBIND AND REBIND Mariangiola Dezani-Ciancaglini 1, Paola

More information

Scoped Types for Real-time Java

Scoped Types for Real-time Java Scoped Types for Real-time Java Tian Zhao University of Wisconsin Milwaukee James Noble Victoria University of Wellington Jan Vitek Purdue University Abstract A memory model based on scoped areas is one

More information

A Type System for Functional Traversal-Based Aspects

A Type System for Functional Traversal-Based Aspects A Type System for Functional Traversal-Based Aspects Bryan Chadwick College of Computer & Information Science Northeastern University, 360 Huntington Avenue Boston, Massachusetts 02115 USA chadwick@ccs.neu.edu

More information

Implicit Ownership Types for Memory Management

Implicit Ownership Types for Memory Management Implicit Ownership Types for Memory Management Tian Zhao 1, Jason Baker 2, James Hunt 3, James Noble 4, and Jan Vitek 2 (1) University of Wisconsin Milwaukee, USA (2) Purdue University, West Lafayette,

More information

Programming Languages Lecture 14: Sum, Product, Recursive Types

Programming Languages Lecture 14: Sum, Product, Recursive Types CSE 230: Winter 200 Principles of Programming Languages Lecture 4: Sum, Product, Recursive Types The end is nigh HW 3 No HW 4 (= Final) Project (Meeting + Talk) Ranjit Jhala UC San Diego Recap Goal: Relate

More information

Type assignment for intersections and unions in call-by-value languages

Type assignment for intersections and unions in call-by-value languages Type assignment for intersections and unions in call-by-value languages Joshua Dunfield and Frank Pfenning Triple Project Carnegie Mellon University 8 April 2003 FOSSACS 03, Warsaw, Poland Type assignment

More information

Konzepte von Programmiersprachen

Konzepte von Programmiersprachen Konzepte von Programmiersprachen Chapter 9: Objects and Classes Peter Thiemann Universität Freiburg 9. Juli 2009 Konzepte von Programmiersprachen 1 / 22 Objects state encapsulation (instance vars, fields)

More information

- couldn t be instantiated dynamically! - no type or other method of organizing, despite similarity to

- couldn t be instantiated dynamically! - no type or other method of organizing, despite similarity to Roots in ADT Languages Lecture 20: OOLs CSC 131 Fall, 2014 Kim Bruce Ada and Modula-2 internal reps - couldn t be instantiated dynamically - no type or other method of organizing, despite similarity to

More information

Satisfiability Modulo Theories. DPLL solves Satisfiability fine on some problems but not others

Satisfiability Modulo Theories. DPLL solves Satisfiability fine on some problems but not others DPLL solves Satisfiability fine on some problems but not others DPLL solves Satisfiability fine on some problems but not others Does not do well on proving multipliers correct pigeon hole formulas cardinality

More information

Inheritance Considered Harmful

Inheritance Considered Harmful Inheritance Considered Harmful Inheritance and Reentrance Example: StringOutputStream Robust Variants Forwarding Template Methods / Hooks Inner calls 1 Inheritance Interface Inheritance Subtyping Reuse

More information

University of Magdeburg. School of Computer Science. Diplomarbeit. A Machine-Checked Proof for a Product-Line Aware Type System. Author: Thomas Thüm

University of Magdeburg. School of Computer Science. Diplomarbeit. A Machine-Checked Proof for a Product-Line Aware Type System. Author: Thomas Thüm University of Magdeburg School of Computer Science Diplomarbeit A Machine-Checked Proof for a Product-Line Aware Type System Author: Thomas Thüm January 15, 2010 Advisors: Prof. Dr. rer. nat. habil. Gunter

More information

Object-Oriented Design Lecture 16 CS 3500 Fall 2010 (Pucella) Friday, Nov 12, 2010

Object-Oriented Design Lecture 16 CS 3500 Fall 2010 (Pucella) Friday, Nov 12, 2010 Object-Oriented Design Lecture 16 CS 3500 Fall 2010 (Pucella) Friday, Nov 12, 2010 16 Mutation We have been avoiding mutations until now. But they exist in most languages, including Java and Scala. Some

More information

CS 314 Principles of Programming Languages. Lecture 11

CS 314 Principles of Programming Languages. Lecture 11 CS 314 Principles of Programming Languages Lecture 11 Zheng Zhang Department of Computer Science Rutgers University Wednesday 12 th October, 2016 Zheng Zhang 1 eddy.zhengzhang@cs.rutgers.edu Class Information

More information

G Programming Languages - Fall 2012

G Programming Languages - Fall 2012 G22.2110-003 Programming Languages - Fall 2012 Lecture 12 Thomas Wies New York University Review Last lecture Modules Outline Classes Encapsulation and Inheritance Initialization and Finalization Dynamic

More information

Lecture #23: Conversion and Type Inference

Lecture #23: Conversion and Type Inference Lecture #23: Conversion and Type Inference Administrivia. Due date for Project #2 moved to midnight tonight. Midterm mean 20, median 21 (my expectation: 17.5). Last modified: Fri Oct 20 10:46:40 2006 CS164:

More information

Types. Type checking. Why Do We Need Type Systems? Types and Operations. What is a type? Consensus

Types. Type checking. Why Do We Need Type Systems? Types and Operations. What is a type? Consensus Types Type checking What is a type? The notion varies from language to language Consensus A set of values A set of operations on those values Classes are one instantiation of the modern notion of type

More information

Lecture 5 2D Transformation

Lecture 5 2D Transformation Lecture 5 2D Transformation What is a transformation? In computer graphics an object can be transformed according to position, orientation and size. Exactly what it says - an operation that transforms

More information

Conversion vs. Subtyping. Lecture #23: Conversion and Type Inference. Integer Conversions. Conversions: Implicit vs. Explicit. Object x = "Hello";

Conversion vs. Subtyping. Lecture #23: Conversion and Type Inference. Integer Conversions. Conversions: Implicit vs. Explicit. Object x = Hello; Lecture #23: Conversion and Type Inference Administrivia. Due date for Project #2 moved to midnight tonight. Midterm mean 20, median 21 (my expectation: 17.5). In Java, this is legal: Object x = "Hello";

More information

COMP 4161 NICTA Advanced Course. Advanced Topics in Software Verification. Toby Murray, June Andronick, Gerwin Klein

COMP 4161 NICTA Advanced Course. Advanced Topics in Software Verification. Toby Murray, June Andronick, Gerwin Klein COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Toby Murray, June Andronick, Gerwin Klein λ 1 Last time... λ calculus syntax free variables, substitution β reduction α and η conversion

More information

Topic 16: Issues in compiling functional and object-oriented languages

Topic 16: Issues in compiling functional and object-oriented languages Topic 16: Issues in compiling functional and object-oriented languages COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer 1 Compiling functional and OO languages General structure

More information

Programming Languages and Techniques (CIS120)

Programming Languages and Techniques (CIS120) Programming Languages and Techniques () Lecture 13 February 12, 2018 Mutable State & Abstract Stack Machine Chapters 14 &15 Homework 4 Announcements due on February 20. Out this morning Midterm results

More information

Extending FeatherTrait Java with Interfaces

Extending FeatherTrait Java with Interfaces Theoretical Computer Science 398 (2008) 243 260 www.elsevier.com/locate/tcs Extending FeatherTrait Java with Interfaces Luigi Liquori a,, Arnaud Spiwack b a INRIA Sophia Antipolis - Méditerranée, 2004

More information

CS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find

CS1622. Semantic Analysis. The Compiler So Far. Lecture 15 Semantic Analysis. How to build symbol tables How to use them to find CS1622 Lecture 15 Semantic Analysis CS 1622 Lecture 15 1 Semantic Analysis How to build symbol tables How to use them to find multiply-declared and undeclared variables. How to perform type checking CS

More information

Sheep Cloning with Ownership Types

Sheep Cloning with Ownership Types Sheep Cloning with Ownership Types Paley Li Victoria University of Wellington New Zealand lipale@ecs.vuw.ac.nz Nicholas Cameron Mozilla Corporation ncameron@mozilla.com James Noble Victoria University

More information

JOURNAL OF OBJECT TECHNOLOGY

JOURNAL OF OBJECT TECHNOLOGY JOURNAL OF OBJECT TECHNOLOGY Online at http://www.jot.fm. Published by ETH Zurich, Chair of Software Engineering JOT, 2003 Vol. 2, No. 6, November-December 2003 The Theory of Classification Part 9: Inheritance

More information

Gradual Typing for Functional Languages. Jeremy Siek and Walid Taha (presented by Lindsey Kuper)

Gradual Typing for Functional Languages. Jeremy Siek and Walid Taha (presented by Lindsey Kuper) Gradual Typing for Functional Languages Jeremy Siek and Walid Taha (presented by Lindsey Kuper) 1 Introduction 2 What we want Static and dynamic typing: both are useful! (If you re here, I assume you agree.)

More information

Type Inference. Prof. Clarkson Fall Today s music: Cool, Calm, and Collected by The Rolling Stones

Type Inference. Prof. Clarkson Fall Today s music: Cool, Calm, and Collected by The Rolling Stones Type Inference Prof. Clarkson Fall 2016 Today s music: Cool, Calm, and Collected by The Rolling Stones Review Previously in 3110: Interpreters: ASTs, evaluation, parsing Formal syntax Formal semantics

More information

λ calculus is inconsistent

λ calculus is inconsistent Content Rough timeline COMP 4161 NICTA Advanced Course Advanced Topics in Software Verification Gerwin Klein, June Andronick, Toby Murray λ Intro & motivation, getting started [1] Foundations & Principles

More information