Types for Flexible Objects

Size: px
Start display at page:

Download "Types for Flexible Objects"

Transcription

1 Types for Flexible Objects Building a Typed Scripting Language Pottayil Harisanker Menon, Zachary Palmer, Alexander Rozenshteyn, Scott F. Smith The Johns Hopkins University November 17th, 2014

2 2/1 Objective Flexible OO language

3 2/1 Objective Flexible OO language + Static typing, inference, etc.

4 3/1 What is flexible? Freely transition between views on data

5 3/1 What is flexible? Freely transition between views on data Freely manipulate data at runtime

6 3/1 What is flexible? Freely transition between views on data Freely manipulate data at runtime Python, Javascript, Ruby

7 3/1 What is flexible? Freely transition between views on data Freely manipulate data at runtime Python, Javascript, Ruby Objects are dictionaries (almost seamlessly)

8 3/1 What is flexible? Freely transition between views on data Freely manipulate data at runtime Python, Javascript, Ruby Objects are dictionaries (almost seamlessly) Dynamic lookup, update, etc. based on runtime conditions

9 3/1 What is flexible? Freely transition between views on data Freely manipulate data at runtime Python, Javascript, Ruby Objects are dictionaries (almost seamlessly) Dynamic lookup, update, etc. based on runtime conditions Minimal semantic clutter (for readability)

10 3/1 What is flexible? Freely transition between views on data Freely manipulate data at runtime Python, Javascript, Ruby Objects are dictionaries (almost seamlessly) Dynamic lookup, update, etc. based on runtime conditions Minimal semantic clutter (for readability) Good for ad-hoc, situational requirements

11 4/1 Examples of Flexibility Add a method to an existing object: class A: def foo (): return 1 a = A() a. bar = types. MethodType ( lambda self : 2, a)

12 4/1 Examples of Flexibility Rely on execution path invariants: def neg (x): if type(x) is int: return -x else: return not x print neg (2) + 3

13 5/1 Why Types? Flexible languages are good:

14 5/1 Why Types? Flexible languages are good: Faster development

15 5/1 Why Types? Flexible languages are good: Faster development Capture complex ideas with clever patterns

16 5/1 Why Types? Flexible languages are good: Faster development Capture complex ideas with clever patterns Structurally typed ( duck typing )

17 5/1 Why Types? Flexible languages are good: Faster development Capture complex ideas with clever patterns Structurally typed ( duck typing ) Static types are good:

18 5/1 Why Types? Flexible languages are good: Faster development Capture complex ideas with clever patterns Structurally typed ( duck typing ) Static types are good: Describe invariants on data

19 5/1 Why Types? Flexible languages are good: Faster development Capture complex ideas with clever patterns Structurally typed ( duck typing ) Static types are good: Describe invariants on data Help programmer understanding

20 5/1 Why Types? Flexible languages are good: Faster development Capture complex ideas with clever patterns Structurally typed ( duck typing ) Static types are good: Describe invariants on data Help programmer understanding Statically identify programming errors

21 5/1 Why Types? Flexible languages are good: Faster development Capture complex ideas with clever patterns Structurally typed ( duck typing ) Static types are good: Describe invariants on data Help programmer understanding Statically identify programming errors Improve runtime performance

22 5/1 Why Types? Flexible languages are good: Faster development Capture complex ideas with clever patterns Structurally typed ( duck typing ) Static types are good: Describe invariants on data Help programmer understanding Statically identify programming errors Improve runtime performance Other static invariants: immutability, limiting data scope, etc.

23 5/1 Why Types? Flexible languages are good: Faster development Capture complex ideas with clever patterns Structurally typed ( duck typing ) Static types are good: Describe invariants on data Help programmer understanding Statically identify programming errors Improve runtime performance Other static invariants: immutability, limiting data scope, etc. We want both!

24 Options? Powerful traditional type system Captures static invariants (monads, dep. types) Often incurs semantic clutter High barrier to entry Not enough flexibility 6/1

25 Options? Powerful traditional type system Captures static invariants (monads, dep. types) Often incurs semantic clutter High barrier to entry Not enough flexibility Build type inference system for existing language (e.g. DRuby) Fundamentally flexible language Limited success: language features defy static typing (e.g. mutable monkeypatching, Python locals) Not enough static typing 6/1

26 Options? Powerful traditional type system Captures static invariants (monads, dep. types) Often incurs semantic clutter High barrier to entry Not enough flexibility Build type inference system for existing language (e.g. DRuby) Fundamentally flexible language Limited success: language features defy static typing (e.g. mutable monkeypatching, Python locals) Not enough static typing Design a language to include statically-typed flex 6/1

27 7/1 TinyBang Start with an ML-like basis

28 7/1 TinyBang Start with an ML-like basis records, variants, patterns, let, refs, inference

29 7/1 TinyBang Start with an ML-like basis records, variants, patterns, let, refs, inference Add flexible properties All types inferred no declarations Structural subtyping ( duck typing ) Powerful record combinators First-class match clauses Refinement on pattern matching

30 7/1 TinyBang Start with an ML-like basis records, variants, patterns, let, refs, inference Add flexible properties All types inferred no declarations Structural subtyping ( duck typing ) Powerful record combinators First-class match clauses Refinement on pattern matching Result: flexible language with static typing

31 8/1 Outline Semantics Powerful records and record combinators First-class match clauses Object encoding using variants Static typing Overview Union elimination Polymorphism Summary

32 9/1 Asymmetric Concatenation Use type-indexed records [Blume et. al. 06]

33 9/1 Asymmetric Concatenation Use type-indexed records [Blume et. al. 06] {int = 4, A = {int = 5}}

34 9/1 Asymmetric Concatenation Use type-indexed records [Blume et. al. 06] {int = 4, A = {int = 5}} 4 & `A 5

35 9/1 Asymmetric Concatenation Use type-indexed records [Blume et. al. 06] {int = 4, A = {int = 5}} 4 & `A 5 Note: 1-ary record = 1-ary variant

36 9/1 Asymmetric Concatenation Use type-indexed records [Blume et. al. 06] {int = 4, A = {int = 5}} 4 & `A 5 Note: 1-ary record = 1-ary variant Concatenation asymmetrically prefers left components `A 4 & `B 6 & `A 3 = `A 4 & `B 6

37 9/1 Asymmetric Concatenation Use type-indexed records [Blume et. al. 06] {int = 4, A = {int = 5}} 4 & `A 5 Note: 1-ary record = 1-ary variant Concatenation asymmetrically prefers left components `A 4 & `B 6 & `A 3 = `A 4 & `B 6 Asymmetry is fundamental in several encodings

38 10/1 Outline Semantics Powerful records and record combinators First-class match clauses Object encoding using variants Static typing Overview Union elimination Polymorphism Summary

39 11/1 Partial Functions All TinyBang functions are partial via pattern-matching:

40 11/1 Partial Functions All TinyBang functions are partial via pattern-matching: int -> 0 matches all records with an int component

41 11/1 Partial Functions All TinyBang functions are partial via pattern-matching: int -> 0 matches all records with an int component int & x -> x is integer identity In patterns, & is conjunction Variables (e.g. x) match anything and bind it

42 11/1 Partial Functions All TinyBang functions are partial via pattern-matching: int -> 0 matches all records with an int component int & x -> x is integer identity In patterns, & is conjunction Variables (e.g. x) match anything and bind it Pattern-matching takes the leftmost match (`B x -> x+1) (`A 3 & `B 1) 2 (`B x -> x+1) (`B 5 & `A 3 & `B 1) 6

43 11/1 Partial Functions All TinyBang functions are partial via pattern-matching: int -> 0 matches all records with an int component int & x -> x is integer identity In patterns, & is conjunction Variables (e.g. x) match anything and bind it Pattern-matching takes the leftmost match (`B x -> x+1) (`A 3 & `B 1) 2 (`B x -> x+1) (`B 5 & `A 3 & `B 1) 6

44 12/1 Extensible match clauses Single clause: write as function (`l x & `r y -> x + y)

45 12/1 Extensible match clauses Single clause: write as function (`l x & `r y -> x + y) Concatenate functions (&) for multiple clauses (`l x & `r y -> x + y) & ( int & z -> z + 1)

46 12/1 Extensible match clauses Single clause: write as function (`l x & `r y -> x + y) Concatenate functions (&) for multiple clauses (`l x & `r y -> x + y) & ( int & z -> z + 1) Encodes match!

47 12/1 Extensible match clauses Single clause: write as function (`l x & `r y -> x + y) Concatenate functions (&) for multiple clauses (`l x & `r y -> x + y) & ( int & z -> z + 1) Encodes match! Operator & uniformly concatenates records, match clauses: (`x 1) & (int -> 0)

48 13/1 Outline Semantics Powerful records and record combinators First-class match clauses Object encoding using variants Static typing Overview Union elimination Polymorphism Summary

49 14/1 Variant-Based Object Encoding let rec seal = (see paper ) in let prepoint = `x 2 & `y 4 & ( `mg & `self slf -> slf `gx + slf `gy ) & ( `gx & `self slf -> slf.x) &... in let point = seal prepoint in point `mg // returns 6 & can combine data and match clauses

50 14/1 Variant-Based Object Encoding let rec seal = (see paper ) in let prepoint = `x 2 & `y 4 & ( `mg & `self slf -> slf `gx + slf `gy ) & ( `gx & `self slf -> slf.x) &... in let point = seal prepoint in point `mg // returns 6 & can combine data and match clauses Match clause encoding of objects, not records

51 14/1 Variant-Based Object Encoding let rec seal = (see paper ) in let prepoint = `x 2 & `y 4 & ( `mg & `self slf -> slf `gx + slf `gy ) & ( `gx & `self slf -> slf.x) &... in let point = seal prepoint in point `mg // returns 6 & can combine data and match clauses Match clause encoding of objects, not records Seal is a combinator tying self-reference knot

52 14/1 Variant-Based Object Encoding let rec seal = (see paper ) in let prepoint = `x 2 & `y 4 & ( `mg & `self slf -> slf `gx + slf `gy ) & ( `gx & `self slf -> slf.x) &... in let point = seal prepoint in point `mg // returns 6 & can combine data and match clauses Match clause encoding of objects, not records Seal is a combinator tying self-reference knot Can seal, message, extend, reseal, message

53 14/1 Variant-Based Object Encoding let rec seal = (see paper ) in let prepoint = `x 2 & `y 4 & ( `mg & `self slf -> slf `gx + slf `gy ) & ( `gx & `self slf -> slf.x) &... in let point = seal prepoint in point `mg // returns 6 & can combine data and match clauses Match clause encoding of objects, not records Seal is a combinator tying self-reference knot Can seal, message, extend, reseal, message All statically typed!

54 Other Encodings Together, type-indexed records and partial functions can encode: 15/1

55 15/1 Other Encodings Together, type-indexed records and partial functions can encode: Conditionals (`True () and `False ()) Variant-based objects Operator overloading Classes, inheritance, subclasses, etc. Mixins, dynamic functional object extension First-class cases Optional arguments etc.

56 Other Encodings Together, type-indexed records and partial functions can encode: Conditionals (`True () and `False ()) Variant-based objects Operator overloading Classes, inheritance, subclasses, etc. Mixins, dynamic functional object extension First-class cases Optional arguments etc. And we can type them! 15/1

57 16/1 Outline Semantics Powerful records and record combinators First-class match clauses Object encoding using variants Static typing Overview Union elimination Polymorphism Summary

58 17/1 Types Rooted in subtype constraint inference (Aiken/Heintze/Pottier)

59 17/1 Types Rooted in subtype constraint inference (Aiken/Heintze/Pottier) With new notions of

60 17/1 Types Rooted in subtype constraint inference (Aiken/Heintze/Pottier) With new notions of Union type elimination

61 17/1 Types Rooted in subtype constraint inference (Aiken/Heintze/Pottier) With new notions of Union type elimination Polymorphism

62 17/1 Types Rooted in subtype constraint inference (Aiken/Heintze/Pottier) With new notions of Union type elimination Polymorphism Metatheory (rule system, soundness, etc)

63 17/1 Types Rooted in subtype constraint inference (Aiken/Heintze/Pottier) With new notions of Union type elimination Polymorphism Metatheory (rule system, soundness, etc) Inspired by program analysis

64 17/1 Types Rooted in subtype constraint inference (Aiken/Heintze/Pottier) With new notions of Union type elimination Polymorphism Metatheory (rule system, soundness, etc) Inspired by program analysis Union elimination: path sensitivity

65 17/1 Types Rooted in subtype constraint inference (Aiken/Heintze/Pottier) With new notions of Union type elimination Polymorphism Metatheory (rule system, soundness, etc) Inspired by program analysis Union elimination: path sensitivity Polymorphism: context sensitivity

66 17/1 Types Rooted in subtype constraint inference (Aiken/Heintze/Pottier) With new notions of Union type elimination Polymorphism Metatheory (rule system, soundness, etc) Inspired by program analysis Union elimination: path sensitivity Polymorphism: context sensitivity Concession: it s whole-program typing

67 18/1 Outline Semantics Powerful records and record combinators First-class match clauses Object encoding using variants Static typing Overview Union elimination Polymorphism Summary

68 Union type elimination Example: patterns `Z and `S `S x on Peano number input 19/1

69 Constraint Closure Constraint closure can now be defined; each step of clo- 19/1 0 V V 0 0 Label Mismatch l 1 <: 0 2 V <: V 0 = l 0 2 only if l 6= l 0 not of the form 0 & 00 or () Union type elimination 0 # V ; V Example: patterns `Z and `S `S x on Peano Fig Type compatibility: does a type match a pattern? number input argument type = [ Z S () slice slice slice some possible slices Z () 4 S G# 4 S S 4 Fig Type compatibility example patterns Z () S S () Matching Type matching directly parallels expression matching. As in the evaluation system, type matching propagates the result of compatibility and uses the place to enforce left precedence of dispatch. Matching 0 1 V 0 ; V1 2 \C 0 is defined as the least relation satisfying the clauses in Figure 3.11.

70 0 V V 0 0 Label Mismatch l 1 <: 0 2 V <: V 0 = l 0 2 only if l 6= l 0 not of the form 0 & 00 or () Union type elimination 0 # V ; V Example: patterns `Z and `S `S x on Peano Fig Type compatibility: does a type match a pattern? number input argument type = Z () [ S slice slice slice some possible slices Z () S S S 4 G# 4 Fig Type compatibility example 4 patterns Z () S S Adaptively eliminate union to depth of pattern Matching Type matching directly parallels expression matching. As in the evaluation system, type matching propagates the result of compatibility and uses the place to enforce left precedence of dispatch. Matching 0 1 V 0 ; V1 2 \C 0 is defined as the least relation satisfying the clauses in Figure () Constraint Closure Constraint closure can now be defined; each step of clo- 19/1

71 0 V V 0 0 Label Mismatch l 1 <: 0 2 V <: V 0 = l 0 2 only if l 6= l 0 not of the form 0 & 00 or () Union type elimination 0 # V ; V Example: patterns `Z and `S `S x on Peano Fig Type compatibility: does a type match a pattern? number input argument type = Z () [ S slice slice slice some possible slices Z () S S S 4 G# 4 Fig Type compatibility example 4 patterns Z () S S Adaptively eliminate union to depth of pattern Matching Type matching directly parallels expression matching. As in the Slices specialize argument type evaluation system, type matching propagates the result of compatibility and uses the place to enforce left precedence of dispatch. Matching 0 1 V 0 ; V1 2 \C 0 is defined as the least relation satisfying the clauses in Figure () Constraint Closure Constraint closure can now be defined; each step of clo- 19/1

72 0 V V 0 0 Label Mismatch l 1 <: 0 2 V <: V 0 = l 0 2 only if l 6= l 0 not of the form 0 & 00 or () Union type elimination 0 # V ; V Example: patterns `Z and `S `S x on Peano Fig Type compatibility: does a type match a pattern? number input argument type = Z () [ S slice slice slice some possible slices Z () S S S 4 G# 4 Fig Type compatibility example 4 patterns Z () S S Adaptively eliminate union to depth of pattern Matching Type matching directly parallels expression matching. As in the Slices specialize argument type evaluation system, type matching propagates the result of compatibility and uses the placelet to enforce f = left (x: precedence `A () of-> dispatch. x.b) Matching & 0 1 V 0 ; V1 2 \C 0 is defined as the least relation (y: `P satisfying () -> the clauses 1) in Figure in f (`A () & `B 5) + f `P () Constraint Closure Constraint closure can now be defined; each step of clo- () 19/1

73 20/1 Outline Semantics Powerful records and record combinators First-class match clauses Object encoding using variants Static typing Overview Union elimination Polymorphism Summary

74 21/1 Inferred function polymorphism let-polymorphism ignores call context

75 21/1 Inferred function polymorphism let-polymorphism ignores call context Program analyses have polyvariance, e.g. ncfa but are brittle to refactoring arbitrary cutoff at n depth

76 21/1 Inferred function polymorphism let-polymorphism ignores call context Program analyses have polyvariance, e.g. ncfa but are brittle to refactoring arbitrary cutoff at n depth Our approach: polyvariance approach with regular expression call strings

77 21/1 Inferred function polymorphism let-polymorphism ignores call context Program analyses have polyvariance, e.g. ncfa but are brittle to refactoring arbitrary cutoff at n depth Our approach: polyvariance approach with regular expression call strings Limits polymorphism of recursion but nothing else

78 21/1 Inferred function polymorphism let-polymorphism ignores call context Program analyses have polyvariance, e.g. ncfa but are brittle to refactoring arbitrary cutoff at n depth Our approach: polyvariance approach with regular expression call strings Limits polymorphism of recursion but nothing else Similar to DCPA and CFA, but optimistic

79 22/1 Outline Semantics Powerful records and record combinators First-class match clauses Object encoding using variants Static typing Overview Union elimination Polymorphism Summary

80 23/1 Summary Existing scripting languages are fundamentally untypeable

81 23/1 Summary Existing scripting languages are fundamentally untypeable So, start with ML and add principled flex

82 23/1 Summary Existing scripting languages are fundamentally untypeable So, start with ML and add principled flex TinyBang is our initial result supports flex but more safely/declaratively

83 24/1 Bigger Picture: BigBang TinyBang is the currently implemented core

84 24/1 Bigger Picture: BigBang TinyBang is the currently implemented core Building a larger language: code in it

85 24/1 Bigger Picture: BigBang TinyBang is the currently implemented core Building a larger language: code in it Also developing compile-time dispatch methodology

86 24/1 Bigger Picture: BigBang TinyBang is the currently implemented core Building a larger language: code in it Also developing compile-time dispatch methodology

87 25/1 Related Work Re-sealing objects generalizes [Fisher Bono 98] Unifying records and variants from [Pottier 00] Type-indexed records [Shields Meijer 01] First-class match generalizes [Blume et. al. 06] CDuce [Castagna et. al. 14] Similar expressiveness in several dimensions CDuce: type checking; TinyBang: type inference

88 Questions? 26/1

Big Bang. Designing a Statically Typed Scripting Language. Pottayil Harisanker Menon, Zachary Palmer, Scott F. Smith, Alexander Rozenshteyn

Big Bang. Designing a Statically Typed Scripting Language. Pottayil Harisanker Menon, Zachary Palmer, Scott F. Smith, Alexander Rozenshteyn Big Bang Designing a Statically Typed Scripting Language Pottayil Harisanker Menon, Zachary Palmer, Scott F. Smith, Alexander Rozenshteyn The Johns Hopkins University June 11, 2012 Scripting Languages!

More information

Types for Flexible Objects

Types for Flexible Objects Types for Flexible Objects Pottayil Harisanker Menon Zachary Palmer Alexander Rozenshteyn Scott Smith The Johns Hopkins University {pharisa2, zachary.palmer, scott, arozens1}@jhu.edu Abstract Scripting

More information

CS558 Programming Languages

CS558 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 information

Overloading, Type Classes, and Algebraic Datatypes

Overloading, Type Classes, and Algebraic Datatypes Overloading, Type Classes, and Algebraic Datatypes Delivered by Michael Pellauer Arvind Computer Science and Artificial Intelligence Laboratory M.I.T. September 28, 2006 September 28, 2006 http://www.csg.csail.mit.edu/6.827

More information

CS-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 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 information

Programming Languages (PL)

Programming Languages (PL) 1 2 3 4 5 6 7 8 9 10 11 Programming Languages (PL) Programming languages are the medium through which programmers precisely describe concepts, formulate algorithms, and reason about solutions. In the course

More information

Types, Type Inference and Unification

Types, Type Inference and Unification Types, Type Inference and Unification Mooly Sagiv Slides by Kathleen Fisher and John Mitchell Cornell CS 6110 Summary (Functional Programming) Lambda Calculus Basic ML Advanced ML: Modules, References,

More information

Types and Type Inference

Types and Type Inference Types and Type Inference Mooly Sagiv Slides by Kathleen Fisher and John Mitchell Reading: Concepts in Programming Languages, Revised Chapter 6 - handout on the course homepage Outline General discussion

More information

COS 320. Compiling Techniques

COS 320. Compiling Techniques Topic 5: Types COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer 1 Types: potential benefits (I) 2 For programmers: help to eliminate common programming mistakes, particularly

More information

CSE341: Programming Languages Lecture 11 Type Inference. Dan Grossman Spring 2016

CSE341: Programming Languages Lecture 11 Type Inference. Dan Grossman Spring 2016 CSE341: Programming Languages Lecture 11 Type Inference Dan Grossman Spring 2016 Type-checking (Static) type-checking can reject a program before it runs to prevent the possibility of some errors A feature

More information

CMSC 330: Organization of Programming Languages

CMSC 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 information

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler Front-End Outline Semantic Analysis The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Static analyses that detect type errors

More information

The role of semantic analysis in a compiler

The role of semantic analysis in a compiler Semantic Analysis Outline The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Static analyses that detect type errors

More information

Cunning Plan. One-Slide Summary. Functional Programming. Functional Programming. Introduction to COOL #1. Classroom Object-Oriented Language

Cunning Plan. One-Slide Summary. Functional Programming. Functional Programming. Introduction to COOL #1. Classroom Object-Oriented Language Functional Programming Introduction to COOL #1 Cunning Plan Functional Programming Types Pattern Matching Higher-Order Functions Classroom Object-Oriented Language Methods Attributes Inheritance Method

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Winter 2017 Lecture 10a Andrew Tolmach Portland State University 1994-2017 Object-oriented Programming Programs are structured in terms of objects: collections of variables

More information

Topics Covered Thus Far. CMSC 330: Organization of Programming Languages. Language Features Covered Thus Far. Programming Languages Revisited

Topics 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 information

The Typed Racket Guide

The Typed Racket Guide The Typed Racket Guide Version 5.3.6 Sam Tobin-Hochstadt and Vincent St-Amour August 9, 2013 Typed Racket is a family of languages, each of which enforce

More information

CSCI-GA Scripting Languages

CSCI-GA Scripting Languages CSCI-GA.3033.003 Scripting Languages 12/02/2013 OCaml 1 Acknowledgement The material on these slides is based on notes provided by Dexter Kozen. 2 About OCaml A functional programming language All computation

More information

Concepts of Programming Languages

Concepts of Programming Languages Concepts of Programming Languages Lecture 15 - Functional Programming Patrick Donnelly Montana State University Spring 2014 Patrick Donnelly (Montana State University) Concepts of Programming Languages

More information

Subprograms. Copyright 2015 Pearson. All rights reserved. 1-1

Subprograms. Copyright 2015 Pearson. All rights reserved. 1-1 Subprograms Introduction Fundamentals of Subprograms Design Issues for Subprograms Local Referencing Environments Parameter-Passing Methods Parameters That Are Subprograms Calling Subprograms Indirectly

More information

CS152: Programming Languages. Lecture 24 Bounded Polymorphism; Classless OOP. Dan Grossman Spring 2011

CS152: Programming Languages. Lecture 24 Bounded Polymorphism; Classless OOP. Dan Grossman Spring 2011 CS152: Programming Languages Lecture 24 Bounded Polymorphism; Classless OOP Dan Grossman Spring 2011 Revenge of Type Variables Sorted lists in ML (partial): type a slist make : ( a -> a -> int) -> a slist

More information

Typed Racket: Racket with Static Types

Typed Racket: Racket with Static Types Typed Racket: Racket with Static Types Version 5.0.2 Sam Tobin-Hochstadt November 6, 2010 Typed Racket is a family of languages, each of which enforce that programs written in the language obey a type

More information

Programming Languages

Programming Languages CSE 130 : Spring 2011 Programming Languages Lecture 13: What s in a Name? Ranjit Jhala UC San Diego Next: What s in a name? More precisely: How should programmer think of data What does a variable x really

More information

Types and Type Inference

Types and Type Inference CS 242 2012 Types and Type Inference Notes modified from John Mitchell and Kathleen Fisher Reading: Concepts in Programming Languages, Revised Chapter 6 - handout on Web!! Outline General discussion of

More information

Next: What s in a name? Programming Languages. Data model in functional PL. What s in a name? CSE 130 : Fall Lecture 13: What s in a Name?

Next: What s in a name? Programming Languages. Data model in functional PL. What s in a name? CSE 130 : Fall Lecture 13: What s in a Name? Next: What s in a name? CSE 13 : Fall 211 Programming Languages Lecture 13: What s in a Name? More precisely: How should programmer think of data What does a variable x really mean? Ranjit Jhala UC San

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

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

(Refer Slide Time: 4:00)

(Refer Slide Time: 4:00) Principles of Programming Languages Dr. S. Arun Kumar Department of Computer Science & Engineering Indian Institute of Technology, Delhi Lecture - 38 Meanings Let us look at abstracts namely functional

More information

Introduction to Programming Using Java (98-388)

Introduction to Programming Using Java (98-388) Introduction to Programming Using Java (98-388) Understand Java fundamentals Describe the use of main in a Java application Signature of main, why it is static; how to consume an instance of your own class;

More information

A Practical Optional Type System for Clojure. Ambrose Bonnaire-Sergeant

A Practical Optional Type System for Clojure. Ambrose Bonnaire-Sergeant A Practical Optional Type System for Clojure Ambrose Bonnaire-Sergeant Statically typed vs. Dynamically typed Traditional distinction Dynamically typed Statically typed eg. Java, C, Haskell eg. Javascript,

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

Topics Covered Thus Far CMSC 330: Organization of Programming Languages

Topics Covered Thus Far CMSC 330: Organization of Programming Languages Topics Covered Thus Far CMSC 330: Organization of Programming Languages Names & Binding, Type Systems Programming languages Ruby Ocaml Lambda calculus Syntax specification Regular expressions Context free

More information

Lecture 7: Type Systems and Symbol Tables. CS 540 George Mason University

Lecture 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 information

Dynamically-typed Languages. David Miller

Dynamically-typed Languages. David Miller Dynamically-typed Languages David Miller Dynamically-typed Language Everything is a value No type declarations Examples of dynamically-typed languages APL, Io, JavaScript, Lisp, Lua, Objective-C, Perl,

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

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

Don 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. 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 information

Chapter 11 Object and Object- Relational Databases

Chapter 11 Object and Object- Relational Databases Chapter 11 Object and Object- Relational Databases Copyright 2011 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Chapter 11 Outline Overview of Object Database Concepts Object-Relational

More information

Formal Systems and their Applications

Formal Systems and their Applications Formal Systems and their Applications Dave Clarke (Dave.Clarke@cs.kuleuven.be) Acknowledgment: these slides are based in part on slides from Benjamin Pierce and Frank Piessens 1 Course Overview Introduction

More information

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Weiss Chapter 1 terminology (parenthesized numbers are page numbers) Weiss Chapter 1 terminology (parenthesized numbers are page numbers) assignment operators In Java, used to alter the value of a variable. These operators include =, +=, -=, *=, and /=. (9) autoincrement

More information

PYTHON CONTENT NOTE: Almost every task is explained with an example

PYTHON CONTENT NOTE: Almost every task is explained with an example PYTHON CONTENT NOTE: Almost every task is explained with an example Introduction: 1. What is a script and program? 2. Difference between scripting and programming languages? 3. What is Python? 4. Characteristics

More information

CSE Lecture 3: Objects 2 September Nate Nystrom University of Texas at Arlington

CSE Lecture 3: Objects 2 September Nate Nystrom University of Texas at Arlington CSE 3302 Lecture 3: Objects 2 September 2010 Nate Nystrom University of Texas at Arlington Administration Out of town this afternoon thru Monday HW1 due next Thursday 9/9 Types Last time: strongly typed

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

Variables and Bindings

Variables and Bindings Net: Variables Variables and Bindings Q: How to use variables in ML? Q: How to assign to a variable? # let = 2+2;; val : int = 4 let = e;; Bind the value of epression e to the variable Variables and Bindings

More information

Functional Programming. Introduction To Cool

Functional Programming. Introduction To Cool Functional Programming Introduction To Cool #1 Cunning Plan ML Functional Programming Fold Sorting Cool Overview Syntax Objects Methods Types #2 This is my final day... as your... companion... through

More information

Chapter 9. Subprograms

Chapter 9. Subprograms Chapter 9 Subprograms Chapter 9 Topics Introduction Fundamentals of Subprograms Design Issues for Subprograms Local Referencing Environments Parameter-Passing Methods Parameters That Are Subprograms Calling

More information

Introduction to Typed Racket. The plan: Racket Crash Course Typed Racket and PL Racket Differences with the text Some PL Racket Examples

Introduction to Typed Racket. The plan: Racket Crash Course Typed Racket and PL Racket Differences with the text Some PL Racket Examples Introduction to Typed Racket The plan: Racket Crash Course Typed Racket and PL Racket Differences with the text Some PL Racket Examples Getting started Find a machine with DrRacket installed (e.g. the

More information

Data Structures (list, dictionary, tuples, sets, strings)

Data Structures (list, dictionary, tuples, sets, strings) Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in brackets: l = [1, 2, "a"] (access by index, is mutable sequence) Tuples are enclosed in parentheses: t = (1, 2, "a") (access

More information

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe

Copyright 2016 Ramez Elmasri and Shamkant B. Navathe Chapter 12 Outline Overview of Object Database Concepts Object-Relational Features Object Database Extensions to SQL ODMG Object Model and the Object Definition Language ODL Object Database Conceptual

More information

CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP. Dan Grossman Winter 2013

CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP. Dan Grossman Winter 2013 CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP Dan Grossman Winter 2013 Ruby logistics Next two sections use the Ruby language http://www.ruby-lang.org/ Installation / basic usage

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 24 Thursday, April 19, 2018 1 Error-propagating semantics For the last few weeks, we have been studying type systems.

More information

Chapter 9. Subprograms

Chapter 9. Subprograms Chapter 9 Subprograms Chapter 9 Topics Introduction Fundamentals of Subprograms Design Issues for Subprograms Local Referencing Environments Parameter-Passing Methods Parameters That Are Subprograms Calling

More information

CS558 Programming Languages Winter 2013 Lecture 8

CS558 Programming Languages Winter 2013 Lecture 8 OBJECT-ORIENTED PROGRAMMING CS558 Programming Languages Winter 2013 Lecture 8 Object-oriented programs are structured in terms of objects: collections of variables ( fields ) and functions ( methods ).

More information

Ruby logistics. CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP. Ruby: Not our focus. Ruby: Our focus. A note on the homework

Ruby logistics. CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP. Ruby: Not our focus. Ruby: Our focus. A note on the homework Ruby logistics CSE341: Programming Languages Lecture 19 Introduction to Ruby and OOP Dan Grossman Autumn 2018 Next two sections use the Ruby language http://www.ruby-lang.org/ Installation / basic usage

More information

Adding GADTs to OCaml the direct approach

Adding GADTs to OCaml the direct approach Adding GADTs to OCaml the direct approach Jacques Garrigue & Jacques Le Normand Nagoya University / LexiFi (Paris) https://sites.google.com/site/ocamlgadt/ Garrigue & Le Normand Adding GADTs to OCaml 1

More information

Python in 10 (50) minutes

Python in 10 (50) minutes Python in 10 (50) minutes https://www.stavros.io/tutorials/python/ Python for Microcontrollers Getting started with MicroPython Donald Norris, McGrawHill (2017) Python is strongly typed (i.e. types are

More information

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler so far

Semantic Analysis. Outline. The role of semantic analysis in a compiler. Scope. Types. Where we are. The Compiler so far Outline Semantic Analysis The role of semantic analysis in a compiler A laundry list of tasks Scope Static vs. Dynamic scoping Implementation: symbol tables Types Statically vs. Dynamically typed languages

More information

CMSC330. Objects, Functional Programming, and lambda calculus

CMSC330. Objects, Functional Programming, and lambda calculus CMSC330 Objects, Functional Programming, and lambda calculus 1 OOP vs. FP Object-oriented programming (OOP) Computation as interactions between objects Objects encapsulate mutable data (state) Accessed

More information

Programming Languages

Programming Languages Programming Languages Types CSCI-GA.2110-001 Summer 2011 What is a type? A type consists of a set of values The compiler/interpreter defines a mapping of these values onto the underlying hardware. 2 /

More information

Outline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring

Outline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring Java Outline Java Models for variables Types and type checking, type safety Interpretation vs. compilation Reasoning about code CSCI 2600 Spring 2017 2 Java Java is a successor to a number of languages,

More information

Chapter 9 Subprograms

Chapter 9 Subprograms Chapter 9 Subprograms We now explore the design of subprograms, including parameter-passing methods, local referencing environment, overloaded subprograms, generic subprograms, and the aliasing and problematic

More information

Modules: Contexts of Template Instantiations and Name Lookup Gabriel Dos Reis Microsoft

Modules: Contexts of Template Instantiations and Name Lookup Gabriel Dos Reis Microsoft Modules: Contexts of Template Instantiations and Name Lookup Gabriel Dos Reis Microsoft Background One of the design principles behind modules is to ensure that the working programmer does not need to

More information

COL728 Minor2 Exam Compiler Design Sem II, Answer all 5 questions Max. Marks: 20

COL728 Minor2 Exam Compiler Design Sem II, Answer all 5 questions Max. Marks: 20 COL728 Minor2 Exam Compiler Design Sem II, 2017-18 Answer all 5 questions Max. Marks: 20 1. Short questions a. Give an example of a program that is not a legal program if we assume static scoping, but

More information

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine.

1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 1. true / false By a compiler we mean a program that translates to code that will run natively on some machine. 2. true / false ML can be compiled. 3. true / false FORTRAN can reasonably be considered

More information

Today: Revisit some objects. Programming Languages. Key data structure: Dictionaries. Using Dictionaries. CSE 130 : Winter 2009

Today: Revisit some objects. Programming Languages. Key data structure: Dictionaries. Using Dictionaries. CSE 130 : Winter 2009 CSE 130 : Winter 2009 Programming Languages Lecture 11: What s in a Name? Today: Revisit some objects Exploit features and build powerful expressions Base: int, float, complex Sequence: string, tuple,

More information

Semantic Analysis. Lecture 9. February 7, 2018

Semantic Analysis. Lecture 9. February 7, 2018 Semantic Analysis Lecture 9 February 7, 2018 Midterm 1 Compiler Stages 12 / 14 COOL Programming 10 / 12 Regular Languages 26 / 30 Context-free Languages 17 / 21 Parsing 20 / 23 Extra Credit 4 / 6 Average

More information

Programming Languages Lecture 15: Recursive Types & Subtyping

Programming Languages Lecture 15: Recursive Types & Subtyping CSE 230: Winter 2008 Principles of Programming Languages Lecture 15: Recursive Types & Subtyping Ranjit Jhala UC San Diego News? Formalize first-order type systems Simple types (integers and booleans)

More information

INF 212 ANALYSIS OF PROG. LANGS FUNCTION COMPOSITION. Instructors: Crista Lopes Copyright Instructors.

INF 212 ANALYSIS OF PROG. LANGS FUNCTION COMPOSITION. Instructors: Crista Lopes Copyright Instructors. INF 212 ANALYSIS OF PROG. LANGS FUNCTION COMPOSITION Instructors: Crista Lopes Copyright Instructors. Topics Recursion Higher-order functions Continuation-Passing Style Monads (take 1) Identity Monad Maybe

More information

02157 Functional Programming. Michael R. Ha. Lecture 2: Functions, Types and Lists. Michael R. Hansen

02157 Functional Programming. Michael R. Ha. Lecture 2: Functions, Types and Lists. Michael R. Hansen Lecture 2: Functions, Types and Lists nsen 1 DTU Compute, Technical University of Denmark Lecture 2: Functions, Types and Lists MRH 13/09/2018 Outline Functions as first-class citizens Types, polymorphism

More information

Datatype declarations

Datatype declarations Datatype declarations datatype suit = HEARTS DIAMONDS CLUBS SPADES datatype a list = nil (* copy me NOT! *) op :: of a * a list datatype a heap = EHEAP HEAP of a * a heap * a heap type suit val HEARTS

More information

CS558 Programming Languages. Winter 2013 Lecture 3

CS558 Programming Languages. Winter 2013 Lecture 3 CS558 Programming Languages Winter 2013 Lecture 3 1 NAMES AND BINDING One essential part of being a high-level language is having convenient names for things: variables constants types functions etc. classes

More information

Design issues for objectoriented. languages. Objects-only "pure" language vs mixed. Are subclasses subtypes of the superclass?

Design issues for objectoriented. languages. Objects-only pure language vs mixed. Are subclasses subtypes of the superclass? Encapsulation Encapsulation grouping of subprograms and the data they manipulate Information hiding abstract data types type definition is hidden from the user variables of the type can be declared variables

More information

A Type is a Set of Values. Here we declare n to be a variable of type int; what we mean, n can take on any value from the set of all integer values.

A Type is a Set of Values. Here we declare n to be a variable of type int; what we mean, n can take on any value from the set of all integer values. Types A Type is a Set of Values Consider the statement: Read Chapter 6 int n; Here we declare n to be a variable of type int; what we mean, n can take on any value from the set of all integer values. Also

More information

CS 430 Spring Mike Lam, Professor. Data Types and Type Checking

CS 430 Spring Mike Lam, Professor. Data Types and Type Checking CS 430 Spring 2015 Mike Lam, Professor Data Types and Type Checking Type Systems Type system Rules about valid types, type compatibility, and how data values can be used Benefits of a robust type system

More information

Overview of Semantic Analysis. Lecture 9

Overview of Semantic Analysis. Lecture 9 Overview of Semantic Analysis Lecture 9 1 Midterm Thursday In class SCPD students come to campus for the exam Material through lecture 8 Open note Laptops OK, but no internet or computation 2 Outline The

More information

CMSC 631 Program Analysis and Understanding. Dynamic Typing, Contracts, and Gradual Typing

CMSC 631 Program Analysis and Understanding. Dynamic Typing, Contracts, and Gradual Typing CMSC 631 Program Analysis and Understanding Dynamic Typing, Contracts, and Gradual Typing Static vs. Dynamic Typing Languages with Static Typing Examples: Ocaml, Java, C#, Scala, Haskell Typechecker proves

More information

System Analysis and Design. Introduction: Object Oriented Design

System Analysis and Design. Introduction: Object Oriented Design System Analysis and Design Introduction: Object Oriented Design Salahaddin University College of Engineering Software Engineering Department 2011-2012 Amanj Sherwany http://www.amanj.me/wiki/doku.php?id=teaching:su:system_analysis_and_design

More information

Programming Languages

Programming Languages CSE 130 : Fall 2009 Programming Languages Lecture 13: Whats in a name? Ranjit Jhala UC San Diego f = open( foo.txt, read ) f.readlines() for l in f.readlines(): f.close ou now know enough to do PA5

More information

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor.

3.Constructors and Destructors. Develop cpp program to implement constructor and destructor. 3.Constructors and Destructors Develop cpp program to implement constructor and destructor. Constructors A constructor is a special member function whose task is to initialize the objects of its class.

More information

The results for a few specific cases below are indicated. allequal ([1,1,1,1]) should return true allequal ([1,1,2,1]) should return false

The results for a few specific cases below are indicated. allequal ([1,1,1,1]) should return true allequal ([1,1,2,1]) should return false Test 1 Multiple Choice. Write your answer to the LEFT of each problem. 4 points each 1. Which celebrity has not received an ACM Turing Award? A. Alan Kay B. John McCarthy C. Dennis Ritchie D. Bjarne Stroustrup

More information

References and Exceptions. CS 565 Lecture 14 4/1/08

References and Exceptions. CS 565 Lecture 14 4/1/08 References and Exceptions CS 565 Lecture 14 4/1/08 References In most languages, variables are mutable: it serves as a name for a location the contents of the location can be overwritten, and still be

More information

22c:111 Programming Language Concepts. Fall Types I

22c:111 Programming Language Concepts. Fall Types I 22c:111 Programming Language Concepts Fall 2008 Types I Copyright 2007-08, The McGraw-Hill Company and Cesare Tinelli. These notes were originally developed by Allen Tucker, Robert Noonan and modified

More information

Typed Scheme: Scheme with Static Types

Typed Scheme: Scheme with Static Types Typed Scheme: Scheme with Static Types Version 4.1.1 Sam Tobin-Hochstadt October 5, 2008 Typed Scheme is a Scheme-like language, with a type system that supports common Scheme programming idioms. Explicit

More information

CEU s (Continuing Education Units) 12 Hours (i.e. Mon Thurs 5 9PM or Sat Sun 8AM 5PM)

CEU s (Continuing Education Units) 12 Hours (i.e. Mon Thurs 5 9PM or Sat Sun 8AM 5PM) Course Name: Intro to Ruby Course Number: WITP 312 Credits: Classroom Hours: 1.2 CEU s (Continuing Education Units) 12 Hours (i.e. Mon Thurs 5 9PM or Sat Sun 8AM 5PM) Flex Training - Classroom and On-Line

More information

Overview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017

Overview of OOP. Dr. Zhang COSC 1436 Summer, /18/2017 Overview of OOP Dr. Zhang COSC 1436 Summer, 2017 7/18/2017 Review Data Structures (list, dictionary, tuples, sets, strings) Lists are enclosed in square brackets: l = [1, 2, "a"] (access by index, is mutable

More information

CSE 413 Languages & Implementation. Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341)

CSE 413 Languages & Implementation. Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341) CSE 413 Languages & Implementation Hal Perkins Winter 2019 Structs, Implementing Languages (credits: Dan Grossman, CSE 341) 1 Goals Representing programs as data Racket structs as a better way to represent

More information

Polymorphism and Type Inference

Polymorphism and Type Inference Polymorphism and Type Inference Volker Stolz stolz@ifi.uio.no Department of Informatics University of Oslo Initially by Gerardo Schneider. Based on John C. Mitchell s slides (Stanford U.) Compile-time

More information

Advances in Programming Languages

Advances in Programming Languages T O Y H Advances in Programming Languages APL8: Multiparameter Type Classes, Constructor Classes Ian Stark School of Informatics The University of Edinburgh Thursday 4 February Semester 2 Week 4 E H U

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Fall 2017 Lecture 3a Andrew Tolmach Portland State University 1994-2017 Binding, Scope, Storage Part of being a high-level language is letting the programmer name things: variables

More information

COMP 181. Agenda. Midterm topics. Today: type checking. Purpose of types. Type errors. Type checking

COMP 181. Agenda. Midterm topics. Today: type checking. Purpose of types. Type errors. Type checking Agenda COMP 181 Type checking October 21, 2009 Next week OOPSLA: Object-oriented Programming Systems Languages and Applications One of the top PL conferences Monday (Oct 26 th ) In-class midterm Review

More information

Recursive Types and Subtyping

Recursive Types and Subtyping Recursive Types and Subtyping #1 One-Slide Summary Recursive types (e.g., list) make the typed lambda calculus as powerful as the untyped lambda calculus. If is a subtype of then any expression of type

More information

Python INTRODUCTION: Understanding the Open source Installation of python in Linux/windows. Understanding Interpreters * ipython.

Python INTRODUCTION: Understanding the Open source Installation of python in Linux/windows. Understanding Interpreters * ipython. INTRODUCTION: Understanding the Open source Installation of python in Linux/windows. Understanding Interpreters * ipython * bpython Getting started with. Setting up the IDE and various IDEs. Setting up

More information

Introduce C# as Object Oriented programming language. Explain, tokens,

Introduce C# as Object Oriented programming language. Explain, tokens, Module 2 98 Assignment 1 Introduce C# as Object Oriented programming language. Explain, tokens, lexicals and control flow constructs. 99 The C# Family Tree C Platform Independence C++ Object Orientation

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 18 Thursday, April 3, 2014 1 Error-propagating semantics For the last few weeks, we have been studying type systems.

More information

Lecture 16: Object Programming Languages

Lecture 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 information

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division DO NOT. P. N.

UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division DO NOT. P. N. CS 164 Fall 2011 UNIVERSITY OF CALIFORNIA Department of Electrical Engineering and Computer Sciences Computer Science Division CS 164: P. N. Hilfinger 1. [2 points] We d like to add inheritance to our

More information

The practice of Mezzo

The practice of Mezzo The practice of Mezzo François Pottier INRIA IHP, April 2014 1 / 83 Acknowledgements Jonathan Protzenko, Thibaut Balabonski, Henri Chataing, Armaël Guéneau, Cyprien Mangin 2 / 83 Overview Two lectures

More information

CS558 Programming Languages

CS558 Programming Languages CS558 Programming Languages Winter 2017 Lecture 4a Andrew Tolmach Portland State University 1994-2017 Semantics and Erroneous Programs Important part of language specification is distinguishing valid from

More information

Objects CHAPTER 6. FIGURE 1. Concrete syntax for the P 3 subset of Python. (In addition to that of P 2.)

Objects CHAPTER 6. FIGURE 1. Concrete syntax for the P 3 subset of Python. (In addition to that of P 2.) CHAPTER 6 Objects The main ideas for this chapter are: objects and classes: objects are values that bundle together some data (attributes) and some functions (methods). Classes are values that describe

More information

CSE341, Spring 2013, Final Examination June 13, 2013

CSE341, Spring 2013, Final Examination June 13, 2013 CSE341, Spring 2013, Final Examination June 13, 2013 Please do not turn the page until 8:30. Rules: The exam is closed-book, closed-note, except for both sides of one 8.5x11in piece of paper. Please stop

More information