Event Type Polymorphism
|
|
- Claude Gaines
- 5 years ago
- Views:
Transcription
1 Event Type Polymorphism Rex D. Fernando Robert Dyer Hridesh Rajan Department of Computer Science Iowa State University This work was supported in part by NSF grant CCF
2 : Code re-use and specialization for event-based separation of concerns Approach: Event Type Polymorphism in Ptolemy Technical Contributions: Formal semantics for event type polymorphism Simpler semantics, when compared to earlier work Rex D. Fernando, Robert Dyer and Hridesh Rajan 1 Event Type Polymorphism
3 An Example - No Event Type Polymorphism Example Revisited - With Event Type Polymorphism AST MultExp DivExp NumExp NumExp NumExp Rex D. Fernando, Robert Dyer and Hridesh Rajan 2 Event Type Polymorphism
4 An Example - No Event Type Polymorphism Example Revisited - With Event Type Polymorphism AST MultExp Events MultVisited DivExp NumExp NumExp NumExp C E class C announces event E Rex D. Fernando, Robert Dyer and Hridesh Rajan 2 Event Type Polymorphism
5 An Example - No Event Type Polymorphism Example Revisited - With Event Type Polymorphism AST MultExp Events MultVisited DivExp NumExp DivVisited NumExp NumExp C E class C announces event E Rex D. Fernando, Robert Dyer and Hridesh Rajan 2 Event Type Polymorphism
6 An Example - No Event Type Polymorphism Example Revisited - With Event Type Polymorphism AST MultExp Events MultVisited DivExp NumExp DivVisited NumExp NumExp NumVisited C E class C announces event E Rex D. Fernando, Robert Dyer and Hridesh Rajan 2 Event Type Polymorphism
7 An Example - No Event Type Polymorphism Example Revisited - With Event Type Polymorphism AST MultExp Events MultVisited Handlers Tracing DivExp NumExp DivVisited TypeCheck NumExp NumExp NumVisited Evaluation C E class C announces event E E H event E's announcement invokes handler H Rex D. Fernando, Robert Dyer and Hridesh Rajan 2 Event Type Polymorphism
8 An Example - No Event Type Polymorphism Example Revisited - With Event Type Polymorphism AST MultExp Events MultVisited Handlers Tracing DivExp NumExp DivVisited TypeCheck NumExp NumExp NumVisited Evaluation C E class C announces event E E H event E's announcement invokes handler H Rex D. Fernando, Robert Dyer and Hridesh Rajan 2 Event Type Polymorphism
9 An Example - No Event Type Polymorphism Example Revisited - With Event Type Polymorphism AST Events Handlers MultExp MultVisited Tracing DivExp NumExp DivVisited TypeCheck NumExp NumExp NumVisited Evaluation C E class C announces event E E H event E's announcement invokes handler H Rex D. Fernando, Robert Dyer and Hridesh Rajan 2 Event Type Polymorphism
10 An Example - No Event Type Polymorphism Example Revisited - With Event Type Polymorphism MultVisited + node : MultExp + left : Exp + right : Exp DivVisited + node : DivExp + left : Exp + right : Exp PlusVisited + node : PlusExp + left : Exp + right : Exp Rex D. Fernando, Robert Dyer and Hridesh Rajan 3 Event Type Polymorphism
11 An Example - No Event Type Polymorphism Example Revisited - With Event Type Polymorphism MultVisited + node : MultExp + left : Exp + right : Exp DivVisited + node : DivExp + left : Exp + right : Exp PlusVisited + node : PlusExp + left : Exp + right : Exp Rex D. Fernando, Robert Dyer and Hridesh Rajan 3 Event Type Polymorphism
12 An Example - No Event Type Polymorphism Example Revisited - With Event Type Polymorphism MultVisited + node : MultExp + left : Exp + right : Exp DivVisited + node : DivExp + left : Exp + right : Exp PlusVisited + node : PlusExp + left : Exp + right : Exp Rex D. Fernando, Robert Dyer and Hridesh Rajan 3 Event Type Polymorphism
13 An Example - No Event Type Polymorphism Example Revisited - With Event Type Polymorphism class ASTTracer { void printmult ( MultVisited next ) { logvisitbegin ( next. node (). getclass ()); next. invoke (); logvisitend ( next. node (). getclass ()); } when MultVisited do printmult ; void printdiv ( DivVisited next ) { logvisitbegin ( next. node (). getclass ()); next. invoke (); logvisitend ( next. node (). getclass ()); } when DivVisited do printdiv ; } void printplus ( PlusVisited next ) { logvisitbegin ( next. node (). getclass ()); next. invoke (); logvisitend ( next. node (). getclass ()); } when PlusVisited do printplus ; Rex D. Fernando, Robert Dyer and Hridesh Rajan 4 Event Type Polymorphism
14 An Example - No Event Type Polymorphism Example Revisited - With Event Type Polymorphism class ASTTracer { void printmult ( MultVisited next ) { logvisitbegin ( next. node (). getclass ()); next. invoke (); logvisitend ( next. node (). getclass ()); } when MultVisited do printmult ; void printdiv ( DivVisited next ) { logvisitbegin ( next. node (). getclass ()); next. invoke (); logvisitend ( next. node (). getclass ()); } when DivVisited do printdiv ; } void printplus ( PlusVisited next ) { logvisitbegin ( next. node (). getclass ()); next. invoke (); logvisitend ( next. node (). getclass ()); } when PlusVisited do printplus ; Rex D. Fernando, Robert Dyer and Hridesh Rajan 5 Event Type Polymorphism
15 An Example - No Event Type Polymorphism Example Revisited - With Event Type Polymorphism Can we re-use code here? What happens if a new AST type is added? What happens if an AST type is removed? Rex D. Fernando, Robert Dyer and Hridesh Rajan 6 Event Type Polymorphism
16 An Example - No Event Type Polymorphism Example Revisited - With Event Type Polymorphism Can we re-use code here? No! Passing event closures (next) as argument is illegal. (to simplify reasoning about invoke/proceed functionality) What happens if a new AST type is added? What happens if an AST type is removed? Rex D. Fernando, Robert Dyer and Hridesh Rajan 6 Event Type Polymorphism
17 An Example - No Event Type Polymorphism Example Revisited - With Event Type Polymorphism Can we re-use code here? No! Passing event closures (next) as argument is illegal. (to simplify reasoning about invoke/proceed functionality) What happens if a new AST type is added? Must update all handlers to support that node type! What happens if an AST type is removed? Rex D. Fernando, Robert Dyer and Hridesh Rajan 6 Event Type Polymorphism
18 An Example - No Event Type Polymorphism Example Revisited - With Event Type Polymorphism Can we re-use code here? No! Passing event closures (next) as argument is illegal. (to simplify reasoning about invoke/proceed functionality) What happens if a new AST type is added? Must update all handlers to support that node type! What happens if an AST type is removed? Must update all handlers and remove that node type! Rex D. Fernando, Robert Dyer and Hridesh Rajan 6 Event Type Polymorphism
19 An Example - No Event Type Polymorphism Example Revisited - With Event Type Polymorphism Can we re-use code here? No! Passing event closures (next) as argument is illegal. (to simplify reasoning about invoke/proceed functionality) What happens if a new AST type is added? Must update all handlers to support that node type! What happens if an AST type is removed? Must update all handlers and remove that node type! Polymorphism can help us here! Rex D. Fernando, Robert Dyer and Hridesh Rajan 6 Event Type Polymorphism
20 An Example - No Event Type Polymorphism Example Revisited - With Event Type Polymorphism ExpVisited + node : Exp BinArithVisited + node : BinArith + left : Exp + right : Exp MultVisited + node : MultExp DivVisited + node : DivExp PlusVisited + node : PlusExp Rex D. Fernando, Robert Dyer and Hridesh Rajan 7 Event Type Polymorphism
21 An Example - No Event Type Polymorphism Example Revisited - With Event Type Polymorphism ExpVisited + node : Exp BinArithVisited + node : BinArith + left : Exp + right : Exp MultVisited + node : MultExp DivVisited + node : DivExp PlusVisited + node : PlusExp Rex D. Fernando, Robert Dyer and Hridesh Rajan 7 Event Type Polymorphism
22 An Example - No Event Type Polymorphism Example Revisited - With Event Type Polymorphism ExpVisited + node : Exp BinArithVisited + node : BinArith + left : Exp + right : Exp MultVisited + node : MultExp DivVisited + node : DivExp PlusVisited + node : PlusExp Rex D. Fernando, Robert Dyer and Hridesh Rajan 7 Event Type Polymorphism
23 An Example - No Event Type Polymorphism Example Revisited - With Event Type Polymorphism class ASTTracer { void printexp ( ExpVisited next ) { logvisitbegin ( next. node (). getclass ()); next. invoke (); logvisitend ( next. node (). getclass ()); } when ExpVisited do printexp ; } Rex D. Fernando, Robert Dyer and Hridesh Rajan 8 Event Type Polymorphism
24 An Example - No Event Type Polymorphism Example Revisited - With Event Type Polymorphism class ASTTracer { void printexp ( ExpVisited next ) { logvisitbegin ( next. node (). getclass ()); next. invoke (); logvisitend ( next. node (). getclass ()); } when ExpVisited do printexp ; } Quantifying over entire event hierarchy by only naming super event! No need to update when a new AST type added! No need to update when an AST type removed! Rex D. Fernando, Robert Dyer and Hridesh Rajan 8 Event Type Polymorphism
25 An Example - No Event Type Polymorphism Example Revisited - With Event Type Polymorphism class ASTTracer { void printexp ( ExpVisited next ) { logvisitbegin ( next. node (). getclass ()); next. invoke (); logvisitend ( next. node (). getclass ()); } when ExpVisited do printexp ; } Quantifying over entire event hierarchy by only naming super event! No need to update when a new AST type added! No need to update when an AST type removed! Let s take a look at the language... Rex D. Fernando, Robert Dyer and Hridesh Rajan 8 Event Type Polymorphism
26 Syntax Type-checking Rules Sub-event Relation decl ::= class c extends d { field* meth* binding* } c event p extends q { form* } where c C, a set of class names d C {Object}, a set of superclass names p P, a set of event type names q P {Event}, a set of super event type names Rex D. Fernando, Robert Dyer and Hridesh Rajan 9 Event Type Polymorphism
27 Syntax Type-checking Rules Sub-event Relation binding ::= when p do m e ::= register(e) unregister(e) announce p (e*) { e } e.invoke() where m M, a set of method names Rex D. Fernando, Robert Dyer and Hridesh Rajan 10 Event Type Polymorphism
28 Syntax Type-checking Rules Sub-event Relation (check event) isclass(c) i [1..n] :: isclass(t i ) p : q Π c event p extends q {t 1 var 1,..., t n var n } : OK Rex D. Fernando, Robert Dyer and Hridesh Rajan 11 Event Type Polymorphism
29 Syntax Type-checking Rules Sub-event Relation ( : Top) isevent(p) p : Event ( : Reflexive) isevent(p) p : p ( : Transitive) isevent(p) isevent(q) isevent(q ) p : q q : q p : q Rex D. Fernando, Robert Dyer and Hridesh Rajan 12 Event Type Polymorphism
30 Syntax Type-checking Rules Sub-event Relation ( : Base) (c event p extends q {t 1 var 1,..., t n var n }) CT isevent(q) [t 1 var 1,..., t m var m] = contextsof (q) i [1..n] :: t i var i [t 1 var 1,..., t n var n ] ( j [1..m] :: t j var i [t 1 var 1,..., t m var m] t i <: t j) p : q contextsof recursively computes the list of all context for an event type q, based on its supertypes Rex D. Fernando, Robert Dyer and Hridesh Rajan 13 Event Type Polymorphism
31 Syntax Type-checking Rules Sub-event Relation New syntax: p extends q Typing rules use new relation: p : q Both depth and width subtyping of context information Rex D. Fernando, Robert Dyer and Hridesh Rajan 14 Event Type Polymorphism
32 Related Work Overview Implicit Invocation + Implicit Announcement [Steimann 2010] Implicit announcement allows ambiguity Harder to reason about what event(s) announced Escala [Gasiunas 2011] Does not support width subtyping Limits the ability to specialize sub-events Rex D. Fernando, Robert Dyer and Hridesh Rajan 15 Event Type Polymorphism
33 Future Work Overview Finish type-soundness proof (in Coq) Implement semantics in OpenJDK-based Ptolemy compiler Non-trivial to implement Rex D. Fernando, Robert Dyer and Hridesh Rajan 16 Event Type Polymorphism
34 : Code re-use and specialization for event-based separation of concerns Ability to quantify over a hierarchy of events Allows for code re-use in event definitions and handlers Better maintenance - for both adding and removing events Approach: Event Type Polymorphism in Ptolemy Event types have inheritance Allow width and depth subtyping of context Handlers also handle sub-events Technical Contributions: Formal semantics for event type polymorphism Simpler semantics, when compared to earlier work Rex D. Fernando, Robert Dyer and Hridesh Rajan 17 Event Type Polymorphism
35 Questions?
36
37 Appendix Full Syntax Auxilliary Methods Type-checking Rules Future Work prog ::= decl* e decl ::= class c extends d { field* meth* binding* } c event p extends q { form* } where c C, a set of class names d C {Object}, a set of superclass names p P, a set of event type names q P {Event}, a set of super event type names Rex D. Fernando, Robert Dyer and Hridesh Rajan 18 Event Type Polymorphism
38 Appendix Full Syntax Auxilliary Methods Type-checking Rules Future Work t ::= c thunk p field ::= c f meth ::= c m (form*) { e } form ::= t var, where var this binding ::= when p do m where f F, a set of field names m M, a set of method names var {this} V, V is a set of variable names Rex D. Fernando, Robert Dyer and Hridesh Rajan 19 Event Type Polymorphism
39 Appendix Full Syntax Auxilliary Methods Type-checking Rules Future Work ep ::= n var ep.f ep!= null ep == ep ep < ep! ep ep && ep e ::= new c() var null e.m(e*) e.f e.f = e cast c e form = e ; e e ; e if (ep) { e } else { e } while (ep) { e } register(e) unregister(e) announce p (e*) { e } e.invoke() where n Z, the set of integers Rex D. Fernando, Robert Dyer and Hridesh Rajan 20 Event Type Polymorphism
40 Appendix Full Syntax Auxilliary Methods Type-checking Rules Future Work (Concrete Type Inh.) var i {var 1,..., var n } concretetype(t i var i, [t 1 var 1,..., t n var n ]) = t i var i (Concrete Type Depth) j [1..n] :: t j var i [t 1 var 1,..., t n var n ] concretetype(t i var i, [t 1 var 1,..., t n var n ]) = t j var i Rex D. Fernando, Robert Dyer and Hridesh Rajan 21 Event Type Polymorphism
41 Appendix Full Syntax Auxilliary Methods Type-checking Rules Future Work (Top Context Vars) contextsof (Event) = (Context Vars) (c event p extends q {t 1 var 1,..., t n var n }) CT [t 1 var 1,..., t m var m] = contextsof (q) contextsof (p) = [ i [1..m] :: concretetype(t i var i, [t 1 var 1,..., t n var n ])] + [ i [1..n] :: t i var i :: var i {var 1,..., var m})] Rex D. Fernando, Robert Dyer and Hridesh Rajan 22 Event Type Polymorphism
42 Appendix Full Syntax Auxilliary Methods Type-checking Rules Future Work ExpVisited + node : Exp BinArithVisited + node : BinArith + left : Exp + right : Exp contextsof(expvisited) = [node:exp] contextsof(binarithvisited) = [node:binarith, left:exp, right:exp] contextsof(divvisited) = [node:divexp, left:exp, right:exp] DivVisited + node : DivExp Rex D. Fernando, Robert Dyer and Hridesh Rajan 23 Event Type Polymorphism
43 Appendix Full Syntax Auxilliary Methods Type-checking Rules Future Work (Is Event) (c event p extends q {t 1 var 1,..., t n var n }) CT isevent(p) Rex D. Fernando, Robert Dyer and Hridesh Rajan 24 Event Type Polymorphism
44 Appendix Full Syntax Auxilliary Methods Type-checking Rules Future Work ( : Top) isevent(p) p : Event ( : Refl.) isevent(p) p : p ( : Trans.) isevent(p) isevent(q) isevent(q ) p : q q : q p : q Rex D. Fernando, Robert Dyer and Hridesh Rajan 25 Event Type Polymorphism
45 Appendix Full Syntax Auxilliary Methods Type-checking Rules Future Work ( : Base) (c event p extends q {t 1 var 1,..., t n var n }) CT isevent(q) [t 1 var 1,..., t m var m] = contextsof (q) i [1..n] :: t i var i [t 1 var 1,..., t n var n ] ( j [1..m] :: t j var i [t 1 var 1,..., t m var m] t i <: t j) p : q Rex D. Fernando, Robert Dyer and Hridesh Rajan 26 Event Type Polymorphism
46 Appendix Full Syntax Auxilliary Methods Type-checking Rules Future Work θ ::= type attributes OK program/top-level declaration OK in c method, binding var t var/formal/field exp t expression τ ::= c class type expressions π, Π ::= {I : θ I } I K, type environments where K is finite, K (L {this} V) Rex D. Fernando, Robert Dyer and Hridesh Rajan 27 Event Type Polymorphism
47 Appendix Full Syntax Auxilliary Methods Type-checking Rules Future Work (check event) isclass(c) i [1..n] :: isclass(t i ) p : q Π c event p extends q {t 1 var 1,..., t n var n } : OK Rex D. Fernando, Robert Dyer and Hridesh Rajan 28 Event Type Polymorphism
48 Appendix Full Syntax Auxilliary Methods Type-checking Rules Future Work (check binding) isclass(c ) (c event p extends q {t 1 var 1,..., t n var n }) CT c <: c (c m(thunk p var){e}) = methodbody(c, m) Π when p do m : OK in c Rex D. Fernando, Robert Dyer and Hridesh Rajan 29 Event Type Polymorphism
49 Appendix Full Syntax Auxilliary Methods Type-checking Rules Future Work (announce exp type) (c event p extends q {t 1 var 1,..., t n var n }) CT i [1..n] :: Π e i : exp t i Π e : exp c c <: c Π announce p(e 1,..., e n ) {e} : exp c Rex D. Fernando, Robert Dyer and Hridesh Rajan 30 Event Type Polymorphism
50 Implementation Appendix Full Syntax Auxilliary Methods Type-checking Rules Future Work Static semantics are relatively simple But implementation is non-trivial Handling a supertype event requires the entire hierarchy rooted by that event also be registered But to maintain separate compilation and type checking, event types are only aware of their direct supertype What happens when loading new subtypes and handlers already registered? Rex D. Fernando, Robert Dyer and Hridesh Rajan 31 Event Type Polymorphism
On Exceptions, Events and Observer Chains
Computer Science Technical Reports Computer Science 1-15-2013 On Exceptions, Events and Observer Chains Mehdi Bagherzadeh Iowa State University, mbagherz@iastate.edu Hridesh Rajan Iowa State University
More informationModular Reasoning in the Presence of Event Subtyping
Modular Reasoning in the Presence of Event Subtyping Mehdi Bagherzadeh 1, Robert Dyer 2, Rex D. Fernando 3, José Sánchez 4, and Hridesh Rajan 1 1 Iowa State University, USA {mbagherz,hridesh}@iastate.edu
More informationModular Reasoning in the Presence of Event Subtyping
Modular Reasoning in the Presence of Event Subtyping Mehdi Bagherzadeh α Robert Dyer β Rex D. Fernando γ José Sánchez θ Hridesh Rajan α α Iowa State University, USA β Bowling Green State University, USA
More informationTranslucid Contracts: Expressive Specification and Modular Verification for Aspect-Oriented Interfaces
Translucid Contracts: Expressive Specification and Modular Verification for Aspect-Oriented Interfaces Mehdi Bagherzadeh β, Hridesh Rajan β, Gary T. Leavens θ and Sean Mooney β β Iowa State University,
More informationTranslucid contracts: Expressive specification and modular verification of aspect oriented interfaces
Graduate Theses and Dissertations Iowa State University Capstones, Theses and Dissertations 2011 Translucid contracts: Expressive specification and modular verification of aspect oriented interfaces Mehdi
More informationA Type-and-Effect System for Shared Memory, Concurrent Implicit Invocation Systems
Computer Science Technical Reports Computer Science 12-15-2010 A Type-and-Effect System for Shared Memory, Concurrent Implicit Invocation Systems Yuheng Long Iowa State University, csgzlong@iastate.edu
More informationA Decision Tree-based Approach to Dynamic Pointcut Evaluation
A Decision Tree-based Approach to Dynamic Pointcut Robert Dyer and Hridesh Rajan Department of Computer Science Iowa State University {rdyer,hridesh}@cs.iastate.edu October 19, 2008 Overview Motivation:
More informationA Type-and-Effect System for Shared Memory, Concurrent Implicit Invocation Systems
A Type-and-Effect System for Shared Memory, Concurrent Implicit Invocation Systems Yuheng Long, Tyler Sondag, and Hridesh Rajan TR #10-09a Initial Submission: December 15, 2010. Revised: June 1, 2011.
More informationMid-Term 2 Grades
Mid-Term 2 Grades 100 46 1 HW 9 Homework 9, in untyped class interpreter: Add instanceof Restrict field access to local class Implement overloading (based on argument count) Due date is the same as for
More informationPtolemy: A Language with Quantified, Typed Events
Ptolemy: A Language with Quantified, Typed Events Hridesh Rajan and Gary T. Leavens Iowa State University hridesh@cs.iastate.edu University of Central Florida leavens@eecs.ucf.edu Abstract. Implicit invocation
More informationProject 6 Due 11:59:59pm Thu, Dec 10, 2015
Project 6 Due 11:59:59pm Thu, Dec 10, 2015 Updates None yet. Introduction In this project, you will add a static type checking system to the Rube programming language. Recall the formal syntax for Rube
More informationOperational Semantics 1 / 13
Operational Semantics 1 / 13 Outline What is semantics? Operational Semantics What is semantics? 2 / 13 What is the meaning of a program? Recall: aspects of a language syntax: the structure of its programs
More informationDesign, Semantics and Implementation of the Ptolemy Programming Language: A Language with Quantified Typed Events
Computer Science Technical Reports Computer Science Summer 7-31-2015 Design, Semantics and Implementation of the Ptolemy Programming Language: A Language with Quantified Typed Events Hridesh Rajan Iowa
More informationProject 2 Due 11:59:59pm Wed, Mar 7, 2012
Project 2 Due 11:59:59pm Wed, Mar 7, 2012 Updates Feb 29. Added reflexivity for is subtype. Clarified lca class and castable behavior when given the same class/type. Feb 27. Typo fix (replaced lub with
More informationFeatherweight 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 informationPrinciples of Programming Languages
Principles of Programming Languages Lesson 14 Type Checking Collaboration and Management Dana Fisman www.cs.bgu.ac.il/~ppl172 1 Type Checking We return to the issue of type safety we discussed informally,
More informationCMSC330 Fall 2013 Practice Problems 6 Solutions
CMSC330 Fall 2013 Practice Problems 6 Solutions 1. Programming languages a. Describe how functional programming may be used to simulate OOP. An object may be simulated as a tuple, where each element of
More informationRules and syntax for inheritance. The boring stuff
Rules and syntax for inheritance The boring stuff The compiler adds a call to super() Unless you explicitly call the constructor of the superclass, using super(), the compiler will add such a call for
More informationC++ Important Questions with Answers
1. Name the operators that cannot be overloaded. sizeof,.,.*,.->, ::,? 2. What is inheritance? Inheritance is property such that a parent (or super) class passes the characteristics of itself to children
More informationDon t Believe the Hype. CS152: Programming Languages. Lecture 21 Object-Oriented Programming. Class-based OOP. So what is OOP?
Don t Believe the Hype CS152: Programming Languages Lecture 21 Object-Oriented Programming Dan Grossman Spring 2011 OOP lets you: 1. Build some extensible software concisely 2. Exploit an intuitive analogy
More informationFrom IMP to Java. Andreas Lochbihler. parts based on work by Gerwin Klein and Tobias Nipkow ETH Zurich
From IMP to Java Andreas Lochbihler ETH Zurich parts based on work by Gerwin Klein and Tobias Nipkow 2015-07-14 1 Subtyping 2 Objects and Inheritance 3 Multithreading 1 Subtyping 2 Objects and Inheritance
More informationCompilation 2012 Static Type Checking
Compilation 2012 Jan Midtgaard Michael I. Schwartzbach Aarhus University The Type Checker The type checker has several tasks: determine the types of all expressions check that values and variables are
More informationObject-Oriented Languages. CSc 453. Compilers and Systems Software. 23 : OO Languages. Department of Computer Science University of Arizona
Object-Oriented Languages CSc 453 Compilers and Systems Software 23 : OO Languages Department of Computer Science University of Arizona Object-oriented languages extend imperative languages with: 1 A classification
More informationLanguage Features for Software Evolution and Aspect-Oriented Interfaces: An Exploratory Study
Computer Science Publications Computer Science 2013 Language Features for Software Evolution and Aspect-Oriented Interfaces: An Exploratory Study Robert Dyer Iowa State University Hridesh Rajan Iowa State
More informationLecture 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 informationSoftwaretechnik. 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 informationHomogeneous Family Sharing: Technical report
Homogeneous Family Sharing: Technical report Xin Qi Andrew C. Myers {qixin, andru}@cs.cornell.edu Abstract Recent work has introduced class sharing as a mechanism for adapting a family of related classes
More informationSoftware 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 informationCIS 1.5 Course Objectives. a. Understand the concept of a program (i.e., a computer following a series of instructions)
By the end of this course, students should CIS 1.5 Course Objectives a. Understand the concept of a program (i.e., a computer following a series of instructions) b. Understand the concept of a variable
More informationSubtyping 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 informationStatic Type Checking. Static Type Checking. The Type Checker. Type Annotations. Types Describe Possible Values
The Type Checker Compilation 2007 The type checker has several tasks: determine the types of all expressions check that values and variables are used correctly resolve certain ambiguities by transformations
More informationTopics Covered Thus Far. CMSC 330: Organization of Programming Languages. Language Features Covered Thus Far. Programming Languages Revisited
CMSC 330: Organization of Programming Languages Type Systems, Names & Binding Topics Covered Thus Far Programming languages Syntax specification Regular expressions Context free grammars Implementation
More informationLecture 16: Object Programming Languages
Lecture 16: Object Programming Languages Introduction Corresponds to EOPL 5.1 and 5.2 Goal: to introduce Object Oriented Programming Language (OOPL) concepts using the EOPL extensible language framework
More informationContents. 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 informationCSc 453. OO Languages. Object-Oriented Languages... Object-Oriented Languages. Compiling OO Languages. Compilers and Systems Software
Slide 22 2 Object-Oriented Languages... 3. Polymorphism, which is the ability of a variable to store values of different types. OO languages support a special kind of polymorphism, called inclusion polymorphism,
More informationJava 5 New Language Features
Java 5 New Language Features Ing. Jeroen Boydens, BLIN prof dr. ir. Eric Steegmans http://users.khbo.be/peuteman/java5/ Enterprise Programming Last session. Jeroen Boydens 1. JDK v1.4: assert 2. Generics
More informationA Short Summary of Javali
A Short Summary of Javali October 15, 2015 1 Introduction Javali is a simple language based on ideas found in languages like C++ or Java. Its purpose is to serve as the source language for a simple compiler
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Type Systems, Names and Binding CMSC 330 - Spring 2013 1 Topics Covered Thus Far! Programming languages Ruby OCaml! Syntax specification Regular expressions
More informationArgument Passing All primitive data types (int etc.) are passed by value and all reference types (arrays, strings, objects) are used through refs.
Local Variable Initialization Unlike instance vars, local vars must be initialized before they can be used. Eg. void mymethod() { int foo = 42; int bar; bar = bar + 1; //compile error bar = 99; bar = bar
More informationCompiler 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 informationCS 342 Lecture 8 Data Abstraction By: Hridesh Rajan
CS 342 Lecture 8 Data Abstraction By: Hridesh Rajan 1 Com S 342 so far So far we have studied: Language design goals, Basic functional programming, Flat recursion over lists, Notion of Scheme procedures
More informationInheritance (Extends) Overriding methods IS-A Vs. HAS-A Polymorphism. superclass. is-a. subclass
Inheritance and Polymorphism Inheritance (Extends) Overriding methods IS-A Vs. HAS-A Polymorphism Inheritance (semantics) We now have two classes that do essentially the same thing The fields are exactly
More informationSOOL, a Simple Object-Oriented Language
10 SOOL, a Simple Object-Oriented Language SOOL In the last two chapters we introduced the formal notation necessary in order to specify programming languages. Now we are ready to present the formal specification
More informationType checking. Jianguo Lu. November 27, slides adapted from Sean Treichler and Alex Aiken s. Jianguo Lu November 27, / 39
Type checking Jianguo Lu November 27, 2014 slides adapted from Sean Treichler and Alex Aiken s Jianguo Lu November 27, 2014 1 / 39 Outline 1 Language translation 2 Type checking 3 optimization Jianguo
More informationCSc 520. Principles of Programming Languages 45: OO Languages Introduction
CSc 520 Principles of Programming Languages 45: OO Languages Introduction Christian Collberg Department of Computer Science University of Arizona collberg@cs.arizona.edu Copyright c 2005 Christian Collberg
More informationTradeoffs. CSE 505: Programming Languages. Lecture 15 Subtyping. Where shall we add useful completeness? Where shall we add completeness?
Tradeoffs CSE 505: Programming Languages Lecture 15 Subtyping Zach Tatlock Autumn 2017 Desirable type system properties (desiderata): soundness - exclude all programs that get stuck completeness - include
More informationCS558 Programming Languages
CS558 Programming Languages Winter 2017 Lecture 7b Andrew Tolmach Portland State University 1994-2017 Values and Types We divide the universe of values according to types A type is a set of values and
More informationSemantic Analysis Type Checking
Semantic Analysis Type Checking Maryam Siahbani CMPT 379 * Slides are modified version of Schwarz s compiler course at Stanford 4/8/2016 1 Type Checking Type errors arise when operations are performed
More informationAnnouncement. Agenda 7/31/2008. Polymorphism, Dynamic Binding and Interface. The class will continue on Tuesday, 12 th August
Polymorphism, Dynamic Binding and Interface 2 4 pm Thursday 7/31/2008 @JD2211 1 Announcement Next week is off The class will continue on Tuesday, 12 th August 2 Agenda Review Inheritance Abstract Array
More information(Not Quite) Minijava
(Not Quite) Minijava CMCS22620, Spring 2004 April 5, 2004 1 Syntax program mainclass classdecl mainclass class identifier { public static void main ( String [] identifier ) block } classdecl class identifier
More informationType Checking. COMP 520: Compiler Design (4 credits) Alexander Krolik MWF 9:30-10:30, TR Bob, from Accounting.
COMP 520 Winter 2018 Type Checking (1) Type Checking COMP 520: Compiler Design (4 credits) Alexander Krolik alexander.krolik@mail.mcgill.ca MWF 9:30-10:30, TR 1080 http://www.cs.mcgill.ca/~cs520/2018/
More informationType Systems. Pierce Ch. 3, 8, 11, 15 CSE
Type Systems Pierce Ch. 3, 8, 11, 15 CSE 6341 1 A Simple Language ::= true false if then else 0 succ pred iszero Simple untyped expressions Natural numbers encoded as succ succ
More informationProject 5 Due 11:59:59pm Wed, Nov 25, 2015 (no late submissions)
Introduction Project 5 Due 11:59:59pm Wed, Nov 25, 2015 (no late submissions) In this project, you will write a compiler for a programming language called Rube, which is a small objectoriented programming
More informationBinghamton University. CS-140 Fall Dynamic Types
Dynamic Types 1 Assignment to a subtype If public Duck extends Bird { Then, you may code:. } Bird bref; Duck quack = new Duck(); bref = quack; A subtype may be assigned where the supertype is expected
More informationChapter 5 Object-Oriented Programming
Chapter 5 Object-Oriented Programming Develop code that implements tight encapsulation, loose coupling, and high cohesion Develop code that demonstrates the use of polymorphism Develop code that declares
More informationObject 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 informationDelegation vs Inheritance for Typestate Analysis
Delegation vs Inheritance for Typestate Analysis Du Li, Alex Potanin, 1 and Jonathan Aldrich Carnegie Mellon University and Victoria University of Wellington 1 {duli, aldrich}@cs.cmu.edu, alex@ecs.vuw.ac.nz
More informationCS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 17: Types and Type-Checking 25 Feb 08
CS412/CS413 Introduction to Compilers Tim Teitelbaum Lecture 17: Types and Type-Checking 25 Feb 08 CS 412/413 Spring 2008 Introduction to Compilers 1 What Are Types? Types describe the values possibly
More informationProgramming Languages and Techniques (CIS120)
Programming Languages and Techniques (CIS120) Lecture 26 March 23, 2016 Inheritance and Dynamic Dispatch Chapter 24 Inheritance Example public class { private int x; public () { x = 0; } public void incby(int
More informationTowards Efficient Java Virtual Machine Support for Dynamic Deployment of Inter-type Declarations
Computer Science Technical Reports Computer Science 3-31-2010 Towards Efficient Java Virtual Machine Support for Dynamic Deployment of Inter-type Declarations Bashar Gharaibeh Iowa State University Hridesh
More informationSubtyping. 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 informationScoping rules match identifier uses with identifier definitions. A type is a set of values coupled with a set of operations on those values.
#1 Type Checking Previously, in PL Scoping rules match identifier uses with identifier definitions. A type is a set of values coupled with a set of operations on those values. A type system specifies which
More informationMining Source Code Repositories with. Boa. Robert Dyer, Hoan Nguyen, Hridesh Rajan, and Tien Nguyen
Mining Source Code Repositories with Boa Robert Dyer, Hoan Nguyen, Hridesh Rajan, and Tien Nguyen {rdyer,hoan,hridesh,tien}@iastate.edu Iowa State University The research and educational activities described
More informationLecture 7: Type Systems and Symbol Tables. CS 540 George Mason University
Lecture 7: Type Systems and Symbol Tables CS 540 George Mason University Static Analysis Compilers examine code to find semantic problems. Easy: undeclared variables, tag matching Difficult: preventing
More informationLecture 8 CS 412/413 Spring '00 -- Andrew Myers 2. Lecture 8 CS 412/413 Spring '00 -- Andrew Myers 4
CS412/413 Introduction to Compilers and Translators Spring 00 Outline Typechecking Symbol tables Using symbol tables for analysis Lecture 8: Semantic Analysis and Symbol Tables Lecture 8 CS 412/413 Spring
More informationCS558 Programming Languages
CS558 Programming Languages Fall 2016 Lecture 7a Andrew Tolmach Portland State University 1994-2016 Values and Types We divide the universe of values according to types A type is a set of values and a
More informationObject Oriented Issues in VDM++
Object Oriented Issues in VDM++ Nick Battle, Fujitsu UK (nick.battle@uk.fujitsu.com) Background VDMJ implemented VDM-SL first (started late 2007) Formally defined. Very few semantic problems VDM++ support
More informationJava Fundamentals (II)
Chair of Software Engineering Languages in Depth Series: Java Programming Prof. Dr. Bertrand Meyer Java Fundamentals (II) Marco Piccioni static imports Introduced in 5.0 Imported static members of a class
More informationFirst-Class Type Classes
First-Class Type Classes Matthieu Sozeau Joint work with Nicolas Oury LRI, Univ. Paris-Sud - Démons Team & INRIA Saclay - ProVal Project Gallium Seminar November 3rd 2008 INRIA Rocquencourt Solutions for
More informationTypes. 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 informationCompiler Errors. Flash CS4 Professional ActionScript 3.0 Language Reference. 1 of 18 9/6/2010 9:40 PM
1 of 18 9/6/2010 9:40 PM Flash CS4 Professional ActionScript 3.0 Language Reference Language Reference only Compiler Errors Home All Packages All Classes Language Elements Index Appendixes Conventions
More informationCS-XXX: Graduate Programming Languages. Lecture 22 Class-Based Object-Oriented Programming. Dan Grossman 2012
CS-XXX: Graduate Programming Languages Lecture 22 Class-Based Object-Oriented Programming Dan Grossman 2012 PL Issues for OOP? OOP lets you: 1. Build some extensible software concisely 2. Exploit an intuitive
More informationFlang typechecker Due: February 27, 2015
CMSC 22610 Winter 2015 Implementation of Computer Languages I Flang typechecker Due: February 27, 2015 Project 3 February 9, 2015 1 Introduction The third project is to implement a type checker for Flang,
More informationThe Case for Simple Object-Orientation in VDM++ Erik Ernst Aarhus University, Denmark
The Case for Simple Object-Orientation in VDM++ Erik Ernst Aarhus University, Denmark An outsider.. My research area is OO language design, implementation, formalization, esp. type systems (virtual classes,
More informationStrict Inheritance. Object-Oriented Programming Spring 2008
Strict Inheritance Object-Oriented Programming 236703 Spring 2008 1 Varieties of Polymorphism P o l y m o r p h i s m A d h o c U n i v e r s a l C o e r c i o n O v e r l o a d i n g I n c l u s i o n
More informationCMSC131. Inheritance. Object. When we talked about Object, I mentioned that all Java classes are "built" on top of that.
CMSC131 Inheritance Object When we talked about Object, I mentioned that all Java classes are "built" on top of that. This came up when talking about the Java standard equals operator: boolean equals(object
More informationProject Overview. 1 Introduction. 2 A quick introduction to SOOL
CMSC 22600 Autumn 2016 Compilers for Computer Languages Handout 1 October 6, 2016 Project Overview 1 Introduction The project for the course is to implement a small object-oriented programming language,
More informationInheritance and object compatibility
Inheritance and object compatibility Object type compatibility An instance of a subclass can be used instead of an instance of the superclass, but not the other way around Examples: reference/pointer can
More informationInheritance -- Introduction
Inheritance -- Introduction Another fundamental object-oriented technique is called inheritance, which, when used correctly, supports reuse and enhances software designs Chapter 8 focuses on: the concept
More informationSome instance messages and methods
Some instance messages and methods x ^x y ^y movedx: dx Dy: dy x
More informationPrinciples of Software Construction: Objects, Design and Concurrency. Polymorphism, part 2. toad Fall 2012
Principles of Software Construction: Objects, Design and Concurrency Polymorphism, part 2 15-214 toad Fall 2012 Jonathan Aldrich Charlie Garrod School of Computer Science 2012 C Garrod, J Aldrich, and
More informationPart III. Chapter 15: Subtyping
Part III Chapter 15: Subtyping Subsumption Subtype relation Properties of subtyping and typing Subtyping and other features Intersection and union types Subtyping Motivation With the usual typing rule
More informationPassing Out Review Forms
Type Checking #1 Passing Out Review Forms #2 One-Slide Summary A type environment gives types for free variables. You typecheck a let-body with an environment that has been updated to contain the new let-variable.
More informationJ&: Nested Intersection for Scalable Software Composition
J&: Nested Intersection for Scalable Software Composition Nathaniel Nystrom Xin Qi Andrew C. Myers Computer Science Department Cornell University {nystrom,qixin,andru@cs.cornell.edu Abstract This paper
More informationIntro to semantics; Small-step semantics Lecture 1 Tuesday, January 29, 2013
Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 1 Tuesday, January 29, 2013 1 Intro to semantics What is the meaning of a program? When we write a program, we use
More informationStrict Inheritance. Object-Oriented Programming Winter
Strict Inheritance Object-Oriented Programming 236703 Winter 2014-5 1 1 Abstractions Reminder A class is an abstraction over objects A class hierarchy is an abstraction over classes Similar parts of different
More informationWhat are the characteristics of Object Oriented programming language?
What are the various elements of OOP? Following are the various elements of OOP:- Class:- A class is a collection of data and the various operations that can be performed on that data. Object- This is
More informationContents. I. Classes, Superclasses, and Subclasses. Topic 04 - Inheritance
Contents Topic 04 - Inheritance I. Classes, Superclasses, and Subclasses - Inheritance Hierarchies Controlling Access to Members (public, no modifier, private, protected) Calling constructors of superclass
More informationCS 321 Homework 4 due 1:30pm, Thursday, March 15, 2012 This homework specification is copyright by Andrew Tolmach. All rights reserved.
CS 321 Homework 4 due 1:30pm, Thursday, March 15, 2012 This homework specification is copyright 2002-2012 by Andrew Tolmach. All rights reserved. Typechecking In this assignment, you will build a type-checker
More informationCMSC 330: Organization of Programming Languages. Formal Semantics of a Prog. Lang. Specifying Syntax, Semantics
Recall Architecture of Compilers, Interpreters CMSC 330: Organization of Programming Languages Source Scanner Parser Static Analyzer Operational Semantics Intermediate Representation Front End Back End
More informationLecture Notes on Programming Languages
Lecture Notes on Programming Languages 85 Lecture 09: Support for Object-Oriented Programming This lecture discusses how programming languages support object-oriented programming. Topics to be covered
More informationProject 5 Due 11:59:59pm Tuesday, April 25, 2017
Project 5 Due 11:59:59pm Tuesday, April 25, 2017 Introduction In this project, you will write a compiler for a programming language called Rube, which is a small objectoriented programming language with
More informationObject Oriented Programming: In this course we began an introduction to programming from an object-oriented approach.
CMSC 131: Chapter 28 Final Review: What you learned this semester The Big Picture Object Oriented Programming: In this course we began an introduction to programming from an object-oriented approach. Java
More information1. Every program must have at least one class declaration. (*) 2. Every class declared in a program must have a distinct identifier.
The J- Language (Static) Semantics Version 1.3 (4/5/07) We define here the syntactic restrictions and static semantics of the simple language J- used in 2006 for 3516ICT assignments. Most of these restrictions
More informationJava Object Oriented Design. CSC207 Fall 2014
Java Object Oriented Design CSC207 Fall 2014 Design Problem Design an application where the user can draw different shapes Lines Circles Rectangles Just high level design, don t write any detailed code
More informationCS/ENGRD 2110 FALL Lecture 6: Consequence of type, casting; function equals
CS/ENGRD 2110 FALL 2018 Lecture 6: Consequence of type, casting; function equals http://courses.cs.cornell.edu/cs2110 Overview references in 2 Quick look at arrays: array Casting among classes cast, object-casting
More information9 Objects and Classes
9 Objects and Classes Many programming tasks require the program to manage some piece of state through an interface. For example, a file system has internal state, but we access and modify that state only
More informationCMSC 330: Organization of Programming Languages
CMSC 330: Organization of Programming Languages Operational Semantics CMSC 330 Summer 2018 1 Formal Semantics of a Prog. Lang. Mathematical description of the meaning of programs written in that language
More informationThe Design of Core C++ (Notes)
The Design of Core C++ (Notes) Uday Reddy May 13, 1994 This note is to define a small formal language called Core C++ which reflects the essential structure of C++. As the name implies, the design only
More informationMining Ultra-Large-Scale Software Repositories with. Boa
Mining Ultra-Large-Scale Software Repositories with Boa Robert Dyer, Hoan Nguyen, Hridesh Rajan, and Tien Nguyen {rdyer,hoan,hridesh,tien}@iastate.edu Iowa State University The research and educational
More information