Side-effect checking for Scala. Lukas Rytz, Martin Odersky, Adriaan Moors Scala Days 2011
|
|
- Edith Goodwin
- 5 years ago
- Views:
Transcription
1 Side-effect checking for Scala Lukas Rytz, Martin Odersky, Adriaan Moors Scala Days 2011
2 Why effect checking? We have at least one post a week where the correct answer is wholly or in part, effect system. [@matthewpocock on scala-internals, May 19] Libraries expect pure code: atomic blocks in STMs, distributed code, DSLs (e.g. Parsers), pattern guards Checkable documentation, guaranteed behavior 2
3 What are side-effects? Everything a function does besides computing the result: read / write a file, modify state, throw an Exception, consume resources, call another side-effecting function Programmers care about side-effects but not always about all of them! 3
4 Control your effects Goal: a system to annotate and verify sideeffects 4
5 Control your effects Goal: a system to annotate and verify sideeffects Popular techniques: As a type and effect system, an extension to the type system Using monads, equivalent to an effect type system [Phil Wadler and Peter Thiemann, 2003] 4
6 Control your effects Goal: a system to annotate and verify sideeffects Popular techniques: As a type and effect system, an extension to the type system Using monads, equivalent to an effect type system [Phil Wadler and Peter Thiemann, 2003] 4
7 Java s checked exceptions An effect system! Methods declare their side-effects Overriding methods need to conform 5
8 Java s checked exceptions An effect system! Methods declare their side-effects Overriding methods need to conform...with one major problem: Writing a method which is polymorphic in the effect is heavily verbose Also, they cannot be turned off 5
9 Java s checked exceptions An effect system! interface StringTrans { public string trans(string s); Methods declare their side-effects Overriding methods need to conform...with one major problem: class Text { public void translines(stringtrans f) {... Writing a method which is polymorphic in the effect is heavily verbose Also, they cannot be turned off 5
10 Java s checked exceptions An effect system! interface StringTrans<E extends Exception> { public Methods string declare trans(string their side-effects s) throws E; Overriding methods need to conform...with one major problem: class Text { public void <E extends Exception> translines(stringtrans<e> f) throws E {... Writing a method which is polymorphic in the effect is heavily verbose Also, they cannot be turned off 5
11 Java s checked exceptions An effect system! Methods declare their side-effects Overriding methods need to conform...with one major problem: Writing a method which is polymorphic in the effect is heavily verbose Also, they cannot be turned off 5
12 Our main goals A syntactically lightweight system for polymorphic effects Open for different kinds of side-effects A framework to facilitate implementing new effect systems 6
13 Properties of effects Idempotent Not ordered ( first A then B ) May semantics: side-effects of a method may occur, but they don t need to 7
14 Lightweight polymorphism The Gist: a higher-oder function has the side-effect of its argument class List[A].. { def map[b](f: A => B): = means: union of the side-effects of all methods of all parameters 8
15 @poly is too coarse In the object-oriented is too coarse: trait Counter { def get: Int; def inc(): Unit def read(c: Counter): = { c.get 9
16 Calls on Parameters Annotate which methods of a parameter are called method m is called on parameter a 10
17 Calls on Parameters Annotate which methods of a parameter are called method m is called on parameter a trait Counter { def get: Int; def inc(): Unit def read(c: Counter): = { c.get 10
18 Parameter Calls annotations form an effect system! Calls to methods on arguments are the effects: def f(a: A, b: B): b.bar()) = { a.foo() a.foo() b.boom() 11
19 Parameter Calls annotations form an effect system! Calls to methods on arguments are the effects: def f(a: A, b: B): b.bar()) = { a.foo() a.foo() b.boom() Effects are idempotent 11
20 Parameter Calls annotations form an effect system! Calls to methods on arguments are the effects: def f(a: A, b: B): b.bar()) = { a.foo() a.foo() b.boom() No ordering 11
21 Parameter Calls annotations form an effect system! Calls to methods on arguments are the effects: def f(a: A, b: B): b.bar()) = { a.foo() a.foo() b.boom() May -semantics 11
22 Parameter Calls annotations form an effect system! Calls to methods on arguments are the effects: def f(a: A, b: B): b.bar()) = { a.foo() a.foo() Effect type error b.boom() 11
23 Parameter Calls annotations form an effect system! Calls to methods on arguments are the effects: def f(a: A, b: B): b.bar()) = { a.foo() a.foo() Effect type error b.boom() We first infer and/or check effects Other effect systems use annotations to implement polymorphism 11
24 map trait List[A] { def map[b](f: A => B): = this match { case x :: xs => f(x) :: xs.map(f) case Nil => Nil 12
25 map trait List[A] { def map[b](f: A => B): = this match { case x :: xs => f(x) :: xs.map(f) case Nil => Nil OK, but map is not actually implemented that way... 12
26 Real-world map The actual implementation trait TraversableLike[+A, +Repr] extends... { this: Repr => def map[b, That](f: A => B) (implicit bf: CanBuildFrom[Repr, B, That]): That = { val b = bf(this) for (a <- this) b += f(a) //foreach(a => b += f(a)) b.result 13
27 Real-world map The actual implementation trait TraversableLike[+A, +Repr] extends... { this: Repr => def map[b, That](f: A => B) (implicit bf: CanBuildFrom[Repr, B, That]): That = { val b = bf(this) for (a <- this) b += f(a) //foreach(a => b += f(a)) b.result We need an effect system for tracking state modifications 13
28 Effect system for state Light in annotation Modular (no whole-program pointer analysis) Allow modifications to local variables and local objects...got inspired by a recently published system called JPure [David J. Pearce, Conference on Compiler Construction, Saarbrücken, 2011] 14
29 Locality Fields marked define the locality of a class Invariant: an object can never be part of more than one locality class HashSet[A] val table: Array[List[A]] 15
30 Locality Fields marked define the locality of a class Invariant: an object can never be part of more than one locality HashSet table class HashSet[A] val table: Array[List[A]] Array 15 List a next List... A... List...
31 Modification effects describe the localities a method modifies class HashSet[A] val table: Array[List[A]] def add(a: A): = { val l = table(a.##) if (!l.contains(a)) table(a.##) = a :: l 16
32 Modification effects describe the localities a method modifies class HashSet[A] val table: Array[List[A]] def add(a: A): = { val l = table(a.##) if (!l.contains(a)) table(a.##) = a :: l A method is pure if it modifies only freshlyallocated objects 16
33 State effect example class HashSet[A] val table: Array[List[A]] def add(a: A): = { val l = table(a.##) if (!l.contains(a)) table(a.##) = a :: l def makeset(): = { val s = new HashSet[Int]() s.add(1) s 17
34 State effect example class HashSet[A] val table: Array[List[A]] def add(a: A): = { val l = table(a.##) if (!l.contains(a)) table(a.##) = a :: l s is freshly allocated def makeset(): = { val s = new HashSet[Int]() s.add(1) s 17
35 State effect example class HashSet[A] val table: Array[List[A]] def add(a: A): = { val l = table(a.##) if (!l.contains(a)) table(a.##) = a :: l s is freshly allocated def makeset(): = { val s = new HashSet[Int]() s.add(1) s mask modification of fresh object 17
36 Freshness Modifications to fresh local objects can be masked new returns a fresh annotation to mark other methods that return a fresh object 18
37 CanBuildFrom, Builder trait CanBuildFrom[-From, -Elem, +To] { def apply[a](f: From): Builder[Elem, 19
38 CanBuildFrom, Builder Returns a fresh builder trait CanBuildFrom[-From, -Elem, +To] { def apply[a](f: From): Builder[Elem, 19
39 CanBuildFrom, Builder Returns a fresh builder trait CanBuildFrom[-From, -Elem, +To] { def apply[a](f: From): Builder[Elem, trait Builder[-B, +That] { def +=(b: B): def result: 19
40 The real map, revisited trait TraversableLike[+A, +Repr] extends... { this: Repr => def map[b, That](f: A => B) (implicit bf: CanBuildFrom[Repr, B, That]): That = { val b = bf(this) for (a <- this) b += f(a) //foreach(a => b += f(a)) b.result 20
41 The real map, revisited trait TraversableLike[+A, +Repr] extends... { this: Repr => def map[b, That](f: A => B) (implicit bf: CanBuildFrom[Repr, B, That]): That = { val b = bf(this) for (a <- this) b += f(a) //foreach(a => b += f(a)) b.result trait CanBuildFrom[-Repr, -B, +That] { def apply(r: Repr): Builder[B, 20
42 The real map, revisited trait TraversableLike[+A, +Repr] extends... { this: Repr => def map[b, That](f: A => B) (implicit bf: CanBuildFrom[Repr, B, That]): That = { val b = bf(this) for (a <- this) b += f(a) //foreach(a => b += f(a)) b.result trait Builder[-B, +That] { def +=(b: B): 20
43 The real map, revisited trait TraversableLike[+A, +Repr] extends... { this: Repr => def map[b, That](f: A => B) (implicit bf: CanBuildFrom[Repr, B, That]): That = { val b = bf(this) for (a <- this) b += f(a) //foreach(a => b += f(a)) b.result def foreach[u](f: A => U): 20
44 The real map, revisited trait TraversableLike[+A, +Repr] extends... { this: Repr def map[b, That](f: A => B) (implicit bf: CanBuildFrom[Repr, B, That]): That = { val b = bf(this) for (a <- this) b += f(a) //foreach(a => b += f(a)) b.result 20
45 Limitations Caches break purity Locality is fixed at definition-site: In (mutable) Set[T], the elements in the set are not part of the set s locality Given a Set[Set[T]], modifying one of the inner sets cannot be interpreted as modifying the outer set. 21
46 (Near) future work Interaction with non-annotated libraries Define default behavior: when should effects be inferred? Benchmark on the Scala library Obtain feedback by releasing a first version to the Community 22
47 Thank you! I m happy to answer questions. 23
Fighting Bit Rot with Types (Experience Report: Scala Collections)
LIPIcs Leibniz International Proceedings in Informatics Fighting Bit Rot with Types (Experience Report: Scala Collections) M. Odersky 1, A. Moors 2 1 EPFL, Switzerland martin.odersky@epfl.ch 2 K.U.Leuven,
More informationScala - Some essential concepts -
Scala - Some essential concepts - Marcel Lüthi Graphics and Vision Research Group Department of Mathematics and Computer Science University of Basel Programming an important activity Data preprocessing
More informationCopyright 2018 Tendril, Inc. All rights reserved.
Type Parameter Power-Up! Variance, Bounds, and Inference INTRO Motivations 3 INTRO Motivations Home Energy Report Generation System Free Monad Workflow stages extending common base class Workflow actions
More informationScala 2.13 Collections. *
[ARRAYDEQUE] Scala 2.13 Collections * https://english.stackexchange.com/questions/226954/how-is-deque-commonly-pronounced ABOUT ME Pathikrit Bhowmick github.com/pathikrit Coatue Management Scala for 5
More informationProgramming in Scala Second Edition
Programming in Scala Second Edition Martin Odersky, Lex Spoon, Bill Venners artima ARTIMA PRESS WALNUT CREEK, CALIFORNIA Contents Contents List of Figures List of Tables List of Listings Foreword Foreword
More informationOverview. Elements of Programming Languages. Advanced constructs. Motivating inner class example
Overview Elements of Programming Languages Lecture 11: Object-oriented functional programming James Cheney University of Edinburgh October 30, 2017 We ve now covered: basics of functional programming (with
More informationUnifying functional and object-oriented programming with Scala 齐琦, 海南大学计算机发展前沿系列课程
Unifying functional and object-oriented programming with Scala, 海南大学计算机发展前沿系列课程 2 原文引用 Odersky, M. and T. Rompf (2014). "Unifying functional and objectoriented programming with Scala." Communications of
More informationCS6202: Advanced Topics in Programming Languages and Systems Lecture 0 : Overview
CS6202: Advanced Topics in Programming Languages and Systems Lecture 0 : Overview Advanced Language Features and Foundations Lecturer : Chin Wei Ngan Email : chinwn@comp.nus.edu.sg Office : S15 06-01 CS6202
More informationImproving Scala's Safe Type-Level Abstraction
Seminar: Program Analysis and Transformation University of Applied Sciences Rapperswil Improving Scala's Safe Type-Level Abstraction Stefan Oberholzer, soberhol@hsr.ch Dez 2010 Abstract Scala cannot nd
More informationScala : an LLVM-targeted Scala compiler
Scala : an LLVM-targeted Scala compiler Da Liu, UNI: dl2997 Contents 1 Background 1 2 Introduction 1 3 Project Design 1 4 Language Prototype Features 2 4.1 Language Features........................................
More informationPhilipp Wille. Beyond Scala s Standard Library
Scala Enthusiasts BS Philipp Wille Beyond Scala s Standard Library OO or Functional Programming? Martin Odersky: Systems should be composed from modules. Modules should be simple parts that can be combined
More informationNotes from a Short Introductory Lecture on Scala (Based on Programming in Scala, 2nd Ed.)
Notes from a Short Introductory Lecture on Scala (Based on Programming in Scala, 2nd Ed.) David Haraburda January 30, 2013 1 Introduction Scala is a multi-paradigm language that runs on the JVM (is totally
More informationCS558 Programming Languages
CS558 Programming Languages Fall 2016 Lecture 6a Andrew Tolmach Portland State University 1994-2016 Functional Programming An alternative paradigm to imperative programming First-class functions Emphasis
More informationScala, Your Next Programming Language
Scala, Your Next Programming Language (or if it is good enough for Twitter, it is good enough for me) WORLDCOMP 2011 By Dr. Mark C. Lewis Trinity University Disclaimer I am writing a Scala textbook that
More informationG Programming Languages - Fall 2012
G22.2110-003 Programming Languages - Fall 2012 Lecture 3 Thomas Wies New York University Review Last week Names and Bindings Lifetimes and Allocation Garbage Collection Scope Outline Control Flow Sequencing
More informationCS205: Scalable Software Systems
CS205: Scalable Software Systems Lecture 4 September 14, 2016 Lecture 4 CS205: Scalable Software Systems September 14, 2016 1 / 16 Quick Recap Things covered so far Problem solving by recursive decomposition
More informationOverview. Elements of Programming Languages. Another example. Consider the humble identity function
Overview Elements of Programming Languages Lecture 8: Polymorphism and type inference James Cheney University of Edinburgh October 21, 2016 This week and next week, we will cover di erent forms of abstraction
More informationClassical Themes of Computer Science
Functional Programming (Part 1/2) Bernhard K. Aichernig Institute for Software Technology Graz University of Technology Austria Winter Term 2017/18 Version: November 22, 2017 1/49 Agenda I Functional Programming?
More informationCompSci 220. Programming Methodology 12: Functional Data Structures
CompSci 220 Programming Methodology 12: Functional Data Structures A Polymorphic Higher- Order Function def findfirst[a](as: Array[A], p: A => Boolean): Int = { def loop(n: Int): Int = if (n >= as.length)
More informationCSE 130, Fall 2006: Final Examination
CSE 130, Fall 2006: Final Examination Name: ID: Instructions, etc. 1. Write your answers in the space provided. 2. Wherever it says explain, write no more than three lines as explanation. The rest will
More informationG Programming Languages - Fall 2012
G22.2110-003 Programming Languages - Fall 2012 Week 13 - Part 1 Thomas Wies New York University Review Last lecture Object Oriented Programming Outline Today: Scala Sources: Programming in Scala, Second
More informationTest Class A. public class A { private int x, y; public int getx() { return x; } public int gety() { return y; }
Test Class A Two simple exampel classes public class A { private int x, y; public int getx() { return x; public int gety() { return y; public A( int ax, int ay ) { x = ax; y = ay; public String tostring()
More informationan overview Alceste Scalas Programming languages reading group
an overview Alceste Scalas Programming languages reading group 31 October 2017 Scala: what s the hype about? Object oriented and functional programming language Runs on the JVM... interoperability with
More informationBibliography. Analyse et Conception Formelle. Lesson 5. Crash Course on Scala. Scala in a nutshell. Outline
Bibliography Analyse et Conception Formelle Lesson 5 Crash Course on Scala Simply Scala. Onlinetutorial: http://www.simply.com/fr http://www.simply.com/ Programming in Scala, M. Odersky, L. Spoon, B. Venners.
More informationWitnessing Purity, Constancy and Mutability APLAS Ben Lippmeier Australian National University 2009/12/14
Witnessing Purity, Constancy and Mutability APLAS 2009 Ben Lippmeier Australian National University 2009/12/14 The hidden cost of state monads map :: (a -> b) -> List a -> List b map f xs = case xs of
More informationConcepts of Object-Oriented Programming Peter Müller
Concepts of Object-Oriented Programming Peter Müller Chair of Programming Methodology Autumn Semester 2017 1.2 Introduction Core Concepts 2 Meeting the Requirements Cooperating Program Parts with Well-Defined
More informationArne Brüsch Philipp Wille. Pattern Matching Syntax
Scala Enthusiasts BS Arne Brüsch Philipp Wille Pattern Matching Syntax Scala Modular programming language Some used to call it objectfunctional 2 Scala Modular programming language Some used to call it
More informationThe Trouble with Types
The Trouble with Types Martin Odersky EPFL and Typesafe Types Everyone has an opinion on them Industry: Used to be the norm (C/C++, Java). Today split about evenly with dynamic. Academia: Static types
More informationConcepts of Object-Oriented Programming Peter Müller
Concepts of Object-Oriented Programming Peter Müller Chair of Programming Methodology Autumn Semester 2017 1.2 Introduction Core Concepts 2 Meeting the Requirements Cooperating Program Parts with Well-Defined
More informationScope & Symbol Table. l Most modern programming languages have some notion of scope.
Scope & Symbol Table l Most modern programming languages have some notion of scope. l Scope defines the lifetime of a program symbol. l If a symbol is no longer accessible then we say that it is out of
More informationScala Style Guide Spring 2018
CS18 Integrated Introduction to Computer Science Fisler, Nelson Scala Style Guide Spring 2018 Contents 1 Introduction 1 2 Naming 1 3 Formatting 2 4 Class Declarations 3 5 Functional Paradigms 4 6 Comments
More informationG Programming Languages - Fall 2012
G22.2110-003 Programming Languages - Fall 2012 Lecture 10 Thomas Wies New York University Review Last class ML Outline Modules Sources: PLP, 3.3.4, 3.3.5, 3.8 McConnell, Steve. Code Complete, Second Edition,
More informationMutation. COS 326 David Walker Princeton University
Mutation COS 326 David Walker Princeton University Mutation? 2 Thus far We have considered the (almost) purely functional subset of Ocaml. We ve had a few side effects: printing & raising exceptions. Two
More informationTo What Extend Is Type Inference for Parameteric Polymorphism Possible in the Presence of Ad-Hoc and Subtype Polymorphism
To What Extend Is Type Inference for Parameteric Polymorphism Possible in the Presence of Ad-Hoc and Subtype Polymorphism Daniel Marty University of Applied Sciences Rapperswil Supervised by Prof. Dr.
More informationCS558 Programming Languages
CS558 Programming Languages Fall 2017 Lecture 7b Andrew Tolmach Portland State University 1994-2017 Type Inference Some statically typed languages, like ML (and to a lesser extent Scala), offer alternative
More informationAdvanced Type System Features Tom Schrijvers. Leuven Haskell User Group
Advanced Type System Features Tom Schrijvers Leuven Haskell User Group Data Recursion Genericity Schemes Expression Problem Monads GADTs DSLs Type Type Families Classes Lists and Effect Free Other Handlers
More informationOptimizing Higher-Order Functions in Scala
Optimizing Higher-Order Functions in Scala Iulian Dragos EPFL Outline A quick tour of Scala Generalities Extension through libraries Closure translation in Scala Cost Optimizations in the Scala compiler
More informationStatic Semantics. Lecture 15. (Notes by P. N. Hilfinger and R. Bodik) 2/29/08 Prof. Hilfinger, CS164 Lecture 15 1
Static Semantics Lecture 15 (Notes by P. N. Hilfinger and R. Bodik) 2/29/08 Prof. Hilfinger, CS164 Lecture 15 1 Current Status Lexical analysis Produces tokens Detects & eliminates illegal tokens Parsing
More informationCSCI-GA Final Exam
CSCI-GA 2110-003 - Final Exam Instructor: Thomas Wies Name: Sample Solution ID: You have 110 minutes time. There are 7 assignments and you can reach 110 points in total. You can solve the exercises directly
More informationCompilers and computer architecture: Semantic analysis
1 / 1 Compilers and computer architecture: Semantic analysis Martin Berger Alex Jeffery October 2018 Recall the function of compilers 2 / 1 3 / 1 Recall the structure of compilers Source program Lexical
More informationTopic VIII. The state of the art Scala < > Scala By Example by M. Odersky. Programming Methods Laboratory, EPFL, 2008.
References: Topic VIII The state of the art Scala < www.scala-lang.org > Scala By Example by M. Odersky. Programming Methods Laboratory, EPFL, 2008. An overview of the Scala programming language by M.
More informationCSE Lecture 7: Polymorphism and generics 16 September Nate Nystrom UTA
CSE 3302 Lecture 7: Polymorphism and generics 16 September 2010 Nate Nystrom UTA 2 Polymorphism poly = many morph = shape Allow a variable to contain values with different types 3 Subtype polymorphism
More informationLast name:... First name:... Department (if not D-INFK):...
Concepts of Object-Oriented Programming AS 2016 Concepts of Object-Oriented Programming Midterm Examination 11.11.2016 Prof. Dr. Peter Müller Last name:................................. First name:.................................
More informationCMSC 330: Organization of Programming Languages. OCaml Imperative Programming
CMSC 330: Organization of Programming Languages OCaml Imperative Programming CMSC330 Spring 2018 1 So Far, Only Functional Programming We haven t given you any way so far to change something in memory
More informationCMSC 330: Organization of Programming Languages. OCaml Imperative Programming
CMSC 330: Organization of Programming Languages OCaml Imperative Programming CMSC330 Fall 2017 1 So Far, Only Functional Programming We haven t given you any way so far to change something in memory All
More informationImplementing Method Type Specialisation In Dotty
École Polytechnique Fédérale de Lausanne Semester Project - LAMP Report Implementing Method Type Specialisation In Dotty Author: Alexandre Sikiaridis Supervised by: Dmitry Petrashko Martin Odersky 05/06/2015
More informationCS558 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 informationFunctional Programming
Functional Programming Final Exam Friday, December 18 2015 First Name: Last Name: Your points are precious, don t let them go to waste! Your Name Work that can t be attributed to you is lost: write your
More informationSynthesis using Variable Elimination
Synthesis using Variable Elimination Viktor Kuncak EPF Lausanne http://lara.epfl.ch/w/impro Implicit Programming at All Levels Opportunities for implicit programming in Development within an IDE InSynth
More informationOCaml Language Choices CMSC 330: Organization of Programming Languages
OCaml Language Choices CMSC 330: Organization of Programming Languages! Implicit or explicit declarations?! Explicit variables must be introduced with let before use! But you don t need to specify types
More informationUsing Scala for building DSL s
Using Scala for building DSL s Abhijit Sharma Innovation Lab, BMC Software 1 What is a DSL? Domain Specific Language Appropriate abstraction level for domain - uses precise concepts and semantics of domain
More informationDelite: A Framework for Heterogeneous Parallel DSLs
Delite: A Framework for Heterogeneous Parallel DSLs Hassan Chafi, Arvind Sujeeth, Kevin Brown, HyoukJoong Lee, Kunle Olukotun Stanford University Tiark Rompf, Martin Odersky EPFL Heterogeneous Parallel
More informationAdding support for CLR Generics
1 / 16 Miguel Garcia http://lamp.epfl.ch/~magarcia LAMP, EPFL 2011-09-06 2 / 16 Outline The original plan: Two easy steps What is Partial Erasure What s missing 1 of 4: Type var bridges for inner classes
More informationFunctions and Objects. Week 7: Symbolic Computation
Week 7: Symbolic Computation In the previous weeks, we've seen the essential elements of modern functional programming: Functions (rst class) Types (parametric) Pattern Matching Lists This week, we'll
More informationFrege. purely functional programming on the JVM. GOTO Berlin 2015
Frege purely functional programming on the JVM GOTO Berlin 2015 Dierk König canoo mittie Dreaming of code Why do we care? a = 1 1 b = 2 1 2 time 1 c = b 1 2 time 2 b = a 1 2 time 3 a = c 1 2 place1 place2
More informationn n Official Scala website n Scala API n
n Quiz 8 Announcements n Rainbow grades: HW1-8, Quiz1-6, Exam1-2 n Still grading: HW9, Quiz 7 Scala n HW10 due today n HW11 out today, due Friday Fall 18 CSCI 4430, A Milanova 1 Today s Lecture Outline
More informationAxiomatic Rules. Lecture 18: Axiomatic Semantics & Type Safety. Correctness using Axioms & Rules. Axiomatic Rules. Steps in Proof
Lecture 18: Axiomatic Semantics & Type Safety CSCI 131 Fall, 2011 Kim Bruce Axiomatic Rules Assignment axiom: - {P [expression / id]} id := expression {P} - Ex: {a+47 > 0} x := a+47 {x > 0} - {x > 1} x
More informationStatic type safety guarantees for the operators of a relational database querying system. Cédric Lavanchy
Static type safety guarantees for the operators of a relational database querying system Cédric Lavanchy June 6, 2008 Contents 1 Previous work 2 2 Goal 3 3 Theory bases 4 3.1 Typing a relation...........................
More informationCS558 Programming Languages
CS558 Programming Languages Winter 2018 Lecture 7b Andrew Tolmach Portland State University 1994-2018 Dynamic Type Checking Static type checking offers the great advantage of catching errors early And
More informationCS Programming Languages: Scala
CS 3101-2 - Programming Languages: Scala Lecture 5: Exceptions, Generic Classes Daniel Bauer (bauer@cs.columbia.edu) November 19, 2014 Daniel Bauer CS3101-2 Scala - 05 - Exceptions, Generic Classes 1/28
More informationCompilers. Type checking. Yannis Smaragdakis, U. Athens (original slides by Sam
Compilers Type checking Yannis Smaragdakis, U. Athens (original slides by Sam Guyer@Tufts) Summary of parsing Parsing A solid foundation: context-free grammars A simple parser: LL(1) A more powerful parser:
More informationScala Concurrency and Parallel Collections
Scala Concurrency and Parallel Collections Concurrent Programming Keijo Heljanko Department of Computer Science University School of Science November 23rd, 2016 Slides by Keijo Heljanko Scala Scala Originally
More informationCS558 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 informationScala. Introduction. Scala
Scala Introduction 1 Scala Scala was proposed by Professor Martin Odersky and his group at EPFL in 2003 to provide a highperformance, concurrent-ready environment for functional programming and object-oriented
More informationLecture 16: Static Semantics Overview 1
Lecture 16: Static Semantics Overview 1 Lexical analysis Produces tokens Detects & eliminates illegal tokens Parsing Produces trees Detects & eliminates ill-formed parse trees Static semantic analysis
More informationCompiler Theory. (Semantic Analysis and Run-Time Environments)
Compiler Theory (Semantic Analysis and Run-Time Environments) 005 Semantic Actions A compiler must do more than recognise whether a sentence belongs to the language of a grammar it must do something useful
More informationCSCE 314 Programming Languages. Type System
CSCE 314 Programming Languages Type System Dr. Hyunyoung Lee 1 Names Names refer to different kinds of entities in programs, such as variables, functions, classes, templates, modules,.... Names can be
More informationTypes. What is a type?
Types What is a type? Type checking Type conversion Aggregates: strings, arrays, structures Enumeration types Subtypes Types, CS314 Fall 01 BGRyder 1 What is a type? A set of values and the valid operations
More informationSequence 5.1 Building stack frames in LLVM
Sequence 5.1 Building stack frames in LLVM P. de Oliveira Castro S. Tardieu 1/13 P. de Oliveira Castro, S. Tardieu Reminder: Stack frames We have seen earlier that: A function can access its local variables
More informationFunctional programming Primer I
Functional programming Primer I COS 320 Compiling Techniques Princeton University Spring 2016 Lennart Beringer 1 Characteristics of functional programming Primary notions: functions and expressions (not
More informationLecture 09: Introduction to Scala
Lecture 09: Introduction to Scala Computer Science Department, University of Crete Multicore Processor Programming Based on slides by D. Malayeri, S.D. Vick, P. Haller, and M. Madsen Pratikakis (CSD) Scala
More informationThe DOT Calculus. (Dependent Object Types) Nada Amin. May 12, flatmap(oslo)
The DOT Calculus (Dependent Object Types) Nada Amin flatmap(oslo) May 12, 2014 1 Types in Scala and DOT 2 Types in Scala modular named type scala.collection.bitset compound type Channel with Logged refined
More informationScala Where It Came From Where It is Going
Scala Where It Came From Where It is Going Scala Days San Francisco Martin Odersky Scala Where It Came From Scala Days San Francisco Martin Odersky Scala is going nowhere Scala is a gateway drug to Haskell
More informationType assignment for intersections and unions in call-by-value languages
Type assignment for intersections and unions in call-by-value languages Joshua Dunfield and Frank Pfenning Triple Project Carnegie Mellon University 8 April 2003 FOSSACS 03, Warsaw, Poland Type assignment
More informationOverview. Elements of Programming Languages. Evaluation order. Evaluation order
Overview Elements of Programming Languages Lecture 15: Evaluation strategies and laziness James Cheney University of Edinburgh November 18, 216 Final few lectures: cross-cutting language design issues
More informationSpot: A Programming Language for Verified Flight Software
Spot: A Programming Language for Verified Flight Software Rob Bocchino (bocchino@jpl.nasa.gov) Ed Gamble (ed.gamble@jpl.nasa.gov) Kim Gostelow Jet Propulsion Laboratory Califor nia Institute of Technology
More informationG Programming Languages - Fall 2012
G22.2110-003 Programming Languages - Fall 2012 Lecture 4 Thomas Wies New York University Review Last week Control Structures Selection Loops Adding Invariants Outline Subprograms Calling Sequences Parameter
More informationC++ Part 2 <: <: C++ Run-Time Representation. Smalltalk vs. C++ Dynamic Dispatch. Smalltalk vs. C++ Dynamic Dispatch
C++ Run-Time Representation Point object Point vtable Code for move C++ Part x y CSCI 4 Stephen Freund ColorPoint object x 4 y 5 c red ColorPoint vtable Code for move Code for darken Data at same offset
More informationCS558 Programming Languages
CS558 Programming Languages Fall 2016 Lecture 3a Andrew Tolmach Portland State University 1994-2016 Formal Semantics Goal: rigorous and unambiguous definition in terms of a wellunderstood formalism (e.g.
More informationClosures. Mooly Sagiv. Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming
Closures Mooly Sagiv Michael Clarkson, Cornell CS 3110 Data Structures and Functional Programming Summary 1. Predictive Parsing 2. Large Step Operational Semantics (Natural) 3. Small Step Operational Semantics
More information9/5/17. The Design and Implementation of Programming Languages. Compilation. Interpretation. Compilation vs. Interpretation. Hybrid Implementation
Language Implementation Methods The Design and Implementation of Programming Languages Compilation Interpretation Hybrid In Text: Chapter 1 2 Compilation Interpretation Translate high-level programs to
More informationSide Effects (3B) Young Won Lim 11/20/17
Side Effects (3B) Copyright (c) 2016-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later
More informationG Programming Languages Spring 2010 Lecture 4. Robert Grimm, New York University
G22.2110-001 Programming Languages Spring 2010 Lecture 4 Robert Grimm, New York University 1 Review Last week Control Structures Selection Loops 2 Outline Subprograms Calling Sequences Parameter Passing
More informationSemantic Modularization Techniques in Practice: A TAPL case study
1 Semantic Modularization Techniques in Practice: A TAPL case study Bruno C. d. S. Oliveira Joint work with Weixin Zhang, Haoyuan Zhang and Huang Li July 17, 2017 Text 2 EVF: An Extensible and Expressive
More informationCOMPUTER SCIENCE TRIPOS
CST.2011.3.1 COMPUTER SCIENCE TRIPOS Part IB Monday 6 June 2011 1.30 to 4.30 COMPUTER SCIENCE Paper 3 Answer five questions. Submit the answers in five separate bundles, each with its own cover sheet.
More informationAn Object Oriented Programming with C
An Object Oriented Programming with C By Tanmay Kasbe Dr. Ravi Singh Pippal IDEA PUBLISHING WWW.ideapublishing.in i Publishing-in-support-of, IDEA PUBLISHING Block- 9b, Transit Flats, Hudco Place Extension
More informationSide Effects (3B) Young Won Lim 11/23/17
Side Effects (3B) Copyright (c) 2016-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later
More informationInheritance (Chapter 7)
Inheritance (Chapter 7) Prof. Dr. Wolfgang Pree Department of Computer Science University of Salzburg cs.uni-salzburg.at Inheritance the soup of the day?! Inheritance combines three aspects: inheritance
More informationA Framework for Object-Oriented Program Analyses via Core-Java
A Framework for Object-Oriented Program Analyses via Core-Java Florin Craciun Hong Yaw Goh Wei-Ngan Chin Department of Computer Science, National University of Singapore {craciunm gohhy chinwn}@comp.nus.edu.sg
More informationCOMP 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 informationThe DOT Calculus. (Dependent Object Types) Nada Amin. June 18, Scala Days
The DOT Calculus (Dependent Object Types) Nada Amin Scala Days June 18, 2014 1 DOT: Dependent Object Types DOT is a core calculus for path-dependent types. Goals simplify Scala s type system by desugaring
More informationPurely Functional I/O in Scala
Purely Functional I/O in Scala Rúnar Óli Bjarnason @runarorama Scala.IO, Paris 2013 What you should take away from this talk You do not need side-effects to do I/O. Purely functional I/O really is pure.
More informationSemantic 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 informationCSCI 3155: Homework Assignment 4
CSCI 3155: Homework Assignment 4 Spring 2012: Due Monday, March 12, 2012 Like last time, find a partner. You will work on this assignment in pairs. However, note that each student needs to submit a write-up
More informationSide Effects (3B) Young Won Lim 11/27/17
Side Effects (3B) Copyright (c) 2016-2017 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later
More informationObjective Questions. BCA Part III Paper XIX (Java Programming) page 1 of 5
Objective Questions BCA Part III page 1 of 5 1. Java is purely object oriented and provides - a. Abstraction, inheritance b. Encapsulation, polymorphism c. Abstraction, polymorphism d. All of the above
More informationCS558 Programming Languages
CS558 Programming Languages Winter 2017 Lecture 6a Andrew Tolmach Portland State University 1994-2017 Iteration into Recursion Any iteration can be written as a recursion, e.g. while (c) {e Scala is equivalent
More informationUNIVERSITY 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 informationPierce Ch. 3, 8, 11, 15. Type Systems
Pierce Ch. 3, 8, 11, 15 Type Systems Goals Define the simple language of expressions A small subset of Lisp, with minor modifications Define the type system of this language Mathematical definition using
More informationCMSC330 Fall 2016 Midterm #1 2:00pm/3:30pm
CMSC330 Fall 2016 Midterm #1 2:00pm/3:30pm Name: Discussion Time: 10am 11am 12pm 1pm 2pm 3pm TA Name (Circle): Alex Austin Ayman Brian Damien Daniel K. Daniel P. Greg Tammy Tim Vitung Will K. Instructions
More information