Principles of Programming Languages

Save this PDF as:
 WORD  PNG  TXT  JPG

Size: px
Start display at page:

Download "Principles of Programming Languages"

Transcription

1 Principles of Programming Languages Collaboration and Management Dana Fisman Lesson 2 - Types with TypeScript 1

2 Types What are types in programming languages? What types are you familiar with? Why are they needed? Why should we distinguish different types? 2

3 Type of Values A value-type defines a set of values. Examples: Booleans { true, false } Numbers { 0, 1, 2,, , 1/3, e, } Strings { a, abc, some words, } Each value-type is associated with a set of operations that can be done on these values. Different value-types are represented differently in memory 3

4 Expressions and Types Programming language use complex expressions. age > 18? true : false Eventually we would like to compute the resulting value of an expression. Different expressions evaluate to different value types. Does the calculation process needs to be aware of types? 4

5 Expressions and Types What if the value of age is ab??? Is it legal? age > 18? true : false If not, when should the error be discovered (compilation-time? run-time?) If yes, what should be the result? 5

6 Why distinguish types? Because some operators (and functions) can operate only on certain types of values 6

7 A Programming Language Syntax Semantics A grammar defining the set of allowed programs Defines the meaning of the program unambiguously Built inductively from atomic elements and operations that can be applied to (possibly compound) elements The definition follows the inductive definition of programs 7

8 Why do we need a formal semantics? So that we can agree what is the output of a given program. o The formal semantics provides an unambiguous definition of what its execution should achieve. o Various tools manipulate programs (compilers, interpreters, debuggers, IDEs, verification tools). o All of these tools must agree upon a formal specification of what is expected when we execute the program. o Without formal semantics we cannot validate the correctness of programs 8

9 Semantic Domain Formal semantics gives rules for translation from one domain (usually the program s syntax) to another formally defined domain. There are various ways to define the semantics of a programming language (denotational, operational, axiomatizational, ) We will use the operational semantics approach. 9

10 Operational Semantics The Operational Semantics approach determines that: the meaning of an expression in the programming language is specified by the computation it induces when it is executed on a machine. It prescribes how to execute the program step by step. When we follow this specification, we can record the steps and keep track of the state of the computation as steps are executed. 10

11 Example using an Imperative Program Initial state: [x:5, y:3, z:7] Program: "z = x; x = y; y = z;" Processes so far Left to process z = x; x = y; y = z; Computation state: x:5 y:3 z:7 11

12 Example using an Imperative Program Initial state: [x:5, y:3, z:7] Program: "z = x; x = y; y = z;" Processes so far Left to process z = x; x = y; y = z; Computation state: x:5 y:3 z:7 x:5 y:3 z:5 12

13 Example using an Imperative Program Initial state: [x:5, y:3, z:7] Program: "z = x; x = y; y = z;" Processes so far Left to process z = x; x = y; y = z; Computation state: x:5 y:3 z:7 x:5 y:3 z:5 x:3 y:3 z:5 13

14 Example using an Imperative Program Initial state: [x:5, y:3, z:7] Program: "z = x; x = y; y = z;" 14 Computation state: x:5 y:3 z:7 Processes so far Left to process z = x; x = y; y = z; x:5 y:3 z:5 x:3 y:3 z:5 The evaluation process results in computation history x:3 y:5 z:5 The new state at each step was determined by applying the semantics of the processed step (here assignment)

15 Operational Semantics Is it a complete recipe for tool implementors? No. The operational semantics provides an abstraction. It does not provide all the details of what should happen in a concrete computation on specific hardware. For example, it does not mention registers, translation to machine language, encoding of data types. The computation history is a formal mathematical object which is in the semantic domain. 15

16 Operational Semantics The rules of the semantics of the specific programming language indicate: o how to select a sub-expression to evaluate at each step of the computation, and o what are the effects on the state of the computation each time a primitive sub-expression is executed o the state of the computation includes the program that is left to process and the environment o the environment includes the information that was recorded and is needed to complete the processing of the program In summary, the operational semantics of the language maps a program and an initial state to a formal structure we call a computation history. 16

17 Expressions vs. Statements Programs in FP are compound expressions (built from sub-expressions using the syntax of the programming language) In FP programs are processed by evaluating expressions Programs in IP are compound statements (built from sub-statements using the syntax of the programming language) In IP programs are processed by executing statements 17

18 In FP programs are expressions Expressions can either be: Atomic not made up of sub-expressions -12 // a number expression true // a boolean expression x // a variable expression Compound made up of sub-expressions according to the syntax 12 >= 7 // made up by applying comparison // to sub-expressions 12 and 7 (x < 100)? -1 : 2 // conditional expression applied // to sub-expressions (x < 100), // -1 and 2 18

19 Expression Tree Expressions are combined recursively to form trees of compound expressions with atomic expressions at the leaves. { let v = 12; (v >= 7)? (v * 3) : 9 } let =? : v 12 >= * 9 v 7 v 3 19

20 Expression Tree Expressions are combined recursively to form trees of compound expressions with atomic expressions at the leaves. { let v = 12; (v >= 7)? (v * 3) : 9 } let =? : v 12 >= * 9 v 7 v 3 20

21 Operational Semantics of FP In FP programs are processed by evaluating expressions The evaluation function maps expressions to values. The operational semantics of an FP language describes how the evaluation function operates over all possible expressions in the language. It is defined inductively over the syntactic structure of expressions. It uses an environment to record the needed info. 21

22 The Evaluation Algorithm Given an expression e o Identify the top-level syntactic construct of e o Identify the immediate sub-expressions of e o Perform the specific evaluation rule defined for the construct of e Continues recursively until there are no subexpressions left to evaluate (when leaves are reached) 22

23 let { let v = <expr>; <body-expr> } Intuitive semantics: Evaluate <body-expr> using local variable v Operational semantics: o Evaluate the <expr> to value v1 o Bind v to v1 o Evaluate <body-expr> to value v2 o Discard the binding of v o Return v2 23

24 Example of Evaluation { let v = 12; (v >= 7)? (v * 3) : 9 } let =? : v 12 >= * 9 Environment v 7 v 3 24

25 Example of Evaluation { let v = 12; (v >= 7)? (v * 3) : 9 } let =? : v 12 >= * 9 Environment v 12 v 7 v 3 25

26 Example of Evaluation { let v = 12; (v >= 7)? (v * 3) : 9 } let? : >= * 9 Environment v 12 v 7 v 3 26

27 Example of Evaluation { let v = 12; (v >= 7)? (v * 3) : 9 } let? : >= * 9 Environment v 12 v 7 v 3 27

28 Example of Evaluation { let v = 12; (v >= 7)? (v * 3) : 9 } let? : true * 9 Environment v 12 v 3 28

29 Example of Evaluation { let v = 12; (v >= 7)? (v * 3) : 9 } let? : true * 9 Environment v 12 v 3 29

30 Example of Evaluation { let v = 12; (v >= 7)? (v * 3) : 9 } let? : true 36 9 Environment v 12 30

31 Example of Evaluation { let v = 12; (v >= 7)? (v * 3) : 9 } let? : true 36 9 Environment v 12 31

32 Example of Evaluation { let v = 12; (v >= 7)? (v * 3) : 9 } let 36 Environment v 12 32

33 Example of Evaluation { let v = 12; (v >= 7)? (v * 3) : 9 } let 36 Environment v 12 33

34 Example of Evaluation { let v = 12; (v >= 7)? (v * 3) : 9 } 36 Environment The evaluation process reduces the expression step by step until the entire expression is reduced to the returned value This process is thus often termed reduction 34

35 Summary - Operational Semantics Semantics gives meaning to the program constructs (by which we can derive the meaning of a complete program) Operational semantics provides the meaning by prescribing step by step evaluation It distinguishes mathematical functions from functions in programming language (which, by the operational semantics we can view as procedures). 35

36 Types of Expressions The Javascript language mixes both expressions and statements (as it is a multi-paradigm language). This makes it difficult to describe completely its operational semantics in a concise manner. We will completely define a smaller language later on in the course, and suffice now with an informal description for Javascript. 36

37 Types of Expressions in Javascript Atomic expressions: number expressions -12, string expressions "abc", boolean expressions false. Compound expressions: arithmetic expressions (10 + v) * (w / 5), conditional expressions (x > 5), ternary conditional expression <condition>? <expr1> : <expr2>. 37

38 Types of Expressions in Javascript Variable bindings: let <var> = <expr1>; <expr2> Function invocation: f(<expr1>,...,<exprn>) Function definition: (<var1>, ) => <expr>. This list of expressions determines the syntax of a subset of programs in Javascript. 38

39 Types in Programming Languages In the same manner that expressions can be atomic or compound, the values that a program generates can be atomic or command no subcomponents numbers booleans Have subcomponents arrays 39

40 Compound Values Ways to create compound variables: o Literals in the program o Using primitive constructs [1,2,3,4,5] [1,2,3].concat([7,27]) [1,2,3,7,27] [1,[100,200],3] How would you write/create such a compound value in Java? 40 o Deserialized from strings that represent compound values according to a value syntax (see the later lecture on JSON for example).

41 Typed vs. Untyped Languages o Typed Languages Require programmers to specify the type of variables upon their declaration o UnTyped Languages C++, Java JavaScript, Scheme, Python Do not have such requirement There are finer classifications of typeness in programming languages What are the advantages and disadvantages of declaring types? 41

42 Typing Errors at Runtime x is untyped function square(x) {return x * x;} Yet, a number value is expected square(3) square( abc ) 42 ==> 9 ==> NaN Not a Number If on evaluation typeincompatibility is discovered usually a runtime error is issued. This is a special numeric value rather than a runtime error

43 When should a runtime error be issued? Python Scheme (+ 3 6) JavaScript ==> 9 ==> 9 ==> 9 abc abc abc ==> abc ==> abc ==> abc ab + cd (+ ab cd ) ab + cd ==> abcd ==> +: contract violation expected: number? given: "ab" argument position: 1st ==> abcd 43 ab + 3 ==> TypeError: must be str, not int (+ ab 3) ab + 3 ==> +: contract violation expected: number? given: "ab" argument position: 1st ==> ab3

44 Javascript Primitives do not Fail Javascript design choice: Primitive operators are extremely flexible and robust Evaluation of strange things do not trigger a runtime-error, instead it either makes automatic conversions or returns special symbols denoting impossible values. "a" > "ab" "a" * 2 "a" && true ==> false ==> 2ab ==> NaN Not a Number ==> true This is a dubious decision - as such automatic handling of unexpected variations is most often a sign of poorly written code and produces surprising results. 44

45 Variable Access in Javascript Accessors to compound data in Javascript do not fail Referencing undefined variables in Javascript do fail 45 let arr=[1,2,3]; arr[10] ==> undefined a special value let map={a:1, b:2} map.c ==> undefined not a rumtime error! let b=2; c; // c is undefined ==> ReferenceError: c is not defined at evalmachine.<anonymous>:3:1 at ContextifyScript.Script.runInThisContext (vm.js:26:33) at Object.exports.runInThisContext (vm.js:79:17) at run ([eval]:608:19) at onrunrequest ([eval]:379:22) at onmessage ([eval]:347:17) at emittwo (events.js:106:13) at process.emit (events.js:191:7) at process.nexttick (internal/child_process.js:752:12) at _combinedtickcallback (internal/process/next_tick.js:6 e.k // e is undefined ==> ReferenceError: E is not defined at evalmachine.<anonymous>:2:1 at ContextifyScript.Script.runInThisContext (vm.js:26: at Object.exports.runInThisContext (vm.js:79:17) at run ([eval]:608:19) at onrunrequest ([eval]:379:22) at onmessage ([eval]:347:17) at emittwo (events.js:106:13) at process.emit (events.js:191:7) at process.nexttick (internal/child_process.js:752:12)

46 Type Safety Can we avoid such errors and unpleasant surprises? What are the benefits of declaring the types of variables? Type safety is the extent to which a programming language discourages or prevents type errors. A type error is erroneous or undesirable program behavior caused by a discrepancy between differing data types for the program's constants, variables, and methods (functions). 46

47 Type Safety Type enforcement can be either: static catching potential errors at compile time, or dynamic associating type information with values at run-time and consulting them as needed to detect imminent errors or a combination of both. Type safety in static-type (compile-time) systems, usually involves a guarantee that the eventual value of any expression will be a legitimate member of that expression's static type. 47

48 Type of Values A value-type defines a set of values. Examples: Booleans { true, false } Numbers { 0, 1, 2,, , 1/3, e, } Strings { a, abc, some words, } Each value-type is associated with a set of operations that can be done on these values. Different value-types are represented differently in memory 48

49 Types: Value vs. Variable type of a value a value always has a type type of a variable a variable are part of expressions it belongs to some set of values on evaluation they are bound to a value 49 perhaps to several a declaration of a type of a variable expresses the programmers intent for the values the variable will assume

50 Types and Set Relations Since value-types define set of values we can reason about them using set theory notions Let T1, T2 denote value-types. We can say that o T1 is a subset of T2 o T1 and T2 are disjoint o T1 is universal (any in Javascript) o T1 is finite o T1 is infinite 50

51 Types and Set Relations We can construct new types using existing types o T1 union T2 o T1 intersection T2 o T1 x T2 (cartesian product) Compound types (such as arrays) can be defined using just these basic set relation operators Programming languages offer additional ways to construct new types These are basically syntactic sugaring 51

52 Javascript vs. Typescript Typescript is an extension of Javascript (every Javascript program is legal Typescript program) In Javascript variables are not typed, values have types Typescript adds the ability to define a type of variable (this is optional) Typescript programs can be translated to Javascript programs 52 This process does both: Eliminates the types definition (so the result is (untyped) Javascript program) Checks types compatibility

53 Javascript Primitive Value Types Ordinary atomic value types o Booleans : { true, false } o Numbers : { 0, 1, 2,, , 1/3, e, } o Strings : { a, abc, some words, } Special atomic value types o null: { null } o undefined: { undefined } 53

54 Javascript Compound Value Types Compound types (types that are built from primitive operators ) o Arrays : - a list of values - values are referred to by their order (first, second, third, etc.) o Maps : [100, 200, 300] The value of pos 0 The value of pos 2 - a list of (key, value) pairs { a : 100, b : 200 } - values are referred to by their keys The value of key b 54

55 Javascript Value Types This is an inductive definition: Atomic : boolean, number, string, null, undefined Compound : array, map The elements of an array/map can be any Javascript data value [100, [1,2], 300] { a : 100, b : 200, c : [1,2], d : {foo : 15}, e : 500} 55

56 More on Compound Value Types in Javascript Compound values can also be constructed by invoking the appropriate constructors and mutators (functions which incrementally change a value). let arrconstructed = Array(1,2,3) arrconstructed ==> [1,2,3] let mapconstructed = {} mapconstructed.a = 1 mapconstructed.b = 2 mapconstructed 56 ==> { a: 1, b: 2 }

57 Types Introspection Different languages offer various levels of introspection / reflection to enable the analysis of the type of values at runtime, or at interpretation /compile-time. Javascript offers very minimal reflection abilities, only the type of atomic value types or the indication that it is compound (unfortunately called object) 57

58 Javascript Types Introspection console.log(typeof("a")) console.log(typeof(6)) console.log(typeof(true) ==> string number boolean let null1 = null; let undef = undefined; console.log(typeof(null1)); console.log(typeof(undef)); 58 ==> object undefined a well known error

59 Javascript Types Introspection let arr1 = [1, 2, 3], arr2 = ['a', 'b', 'c']; console.log(typeof(arr1)); console.log(typeof(arr2)); ==> object object let map1 = { a : 1, b : 2}, map2 = { 'a' : 1, 'b' : 2}; console.log(typeof(map1)); console.log(typeof(map2)); 59 ==> object object

60 Javascript Types Introspection In Javascript typeof is very limited We will see later how Typescript improves capabilities of typeof More specific reflection : let arrins = [1, 2], mapins = { a:1 } console.log(arrins instanceof Array); console.log(mapins instanceof Array); ==> true false 60

61 Javascript Compound Value Getters Compound values can be "put apart" by using getters let arrind = ["a", "b", "c", "d", "e"] console.log(arrind[0]) console.log(arrind[1]) console.log(arrind.slice(1)) console.log(arrind.slice(1,4)) ==> a b [ 'b', 'c', 'd', 'e' ] [ 'b', 'c', 'd' ] 61

62 Javascript Compound Value Getters Compound values can be "put apart" by using getters let mapind = { a : 1, b : 2 } console.log(mapind['a']) console.log(mapind.a) console.log(mapind['b']) console.log(mapind.b) ==>

63 Compound Value Getters Compound values can be "put apart" by using getters let mapkey = { a : 1, b : 2}, arrkey = ['a', 'b', 'c']; console.log(object.keys(mapkey)); console.log(object.keys(arrkey)); ==> [ 'a', 'b' ] [ '0', '1', '2' ] 63

64 Compound Value Getters for (let k in mapkey) { } console.log(`${k} has value ${mapkey[k]}`); for (let i in arrkey) { } console.log(`${i} has value ${arrkey[i]}`); 64 ==> a has value 1 b has value 2 0 has value a 1 has value b 2 has value c The `backward notation` creates interpolated strings ${expression} is replaced by the value of the expression converted to a strings

65 Variable Types in Typescript: Gradual Typing As we said: o In static languages (c++, Java) variables must typed o In dynamic languages (Javascript, Python) variables are not typed - variables are bound to values - we can inspect their values in runtime o Typescript introduces optional variable types into Javascript let typedvarnum : number = 6, typedvarstr : string = "blue", typedvarbool : boolean = true; 65

66 Summary Programming Language semantics defines the requirements for tools that manipulate programs: interpreters, compilers, debuggers etc. helps determine whether two programs are equivalent. 66

67 Summary The Operational Semantics of programming language defines the meaning of programs by mapping programs to evaluation histories. provides recursive evaluation rules for each specific syntactic construct in a programming language. 67

68 Summary Expressions in an FP language are computed into values. This process can be described as reduction. Runtime errors can be triggered when parameters of the wrong type are passed to primitives (in Scheme) or when undefined variables are accessed. Type safety guarantees at compile-time that a welltyped program will not lead to type runtime errors. 68

69 Summary Data types are defined by 2 aspects: they are sets of values and they determine which operations can be used on values. Values can be atomic (no sub-part) or compound (made up of multiple parts). 69

70 Summary Typescript adds the option of gradual typing on top of Javascript. Primitive atomic types in Typescript are number, boolean, string, undefined and null. Primitive compound types in Typescript are array and map. 70

Principles of Programming Languages

Principles of Programming Languages Principles of Programming Languages www.cs.bgu.ac.il/~ppl172 Lesson 4 - Type Checking Collaboration and Management Dana Fisman 1 Why declare types? Declaring types allows the compiler to detect errors

More information

Intro to semantics; Small-step semantics Lecture 1 Tuesday, January 29, 2013

Intro to semantics; Small-step semantics Lecture 1 Tuesday, January 29, 2013 Harvard School of Engineering and Applied Sciences CS 152: Programming Languages Lecture 1 Tuesday, January 29, 2013 1 Intro to semantics What is the meaning of a program? When we write a program, we use

More 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

JavaScript. History. Adding JavaScript to a page. CS144: Web Applications

JavaScript. History. Adding JavaScript to a page. CS144: Web Applications JavaScript Started as a simple script in a Web page that is interpreted and run by the browser Supported by most modern browsers Allows dynamic update of a web page More generally, allows running an arbitrary

More information

Client-Side Web Technologies. JavaScript Part I

Client-Side Web Technologies. JavaScript Part I Client-Side Web Technologies JavaScript Part I JavaScript First appeared in 1996 in Netscape Navigator Main purpose was to handle input validation that was currently being done server-side Now a powerful

More information

Ruby: Introduction, Basics

Ruby: Introduction, Basics Ruby: Introduction, Basics Computer Science and Engineering College of Engineering The Ohio State University Lecture 4 Ruby vs Java: Similarities Imperative and object-oriented Classes and instances (ie

More information

A Short Summary of Javali

A Short Summary of Javali A Short Summary of Javali October 15, 2015 1 Introduction Javali is a simple language based on ideas found in languages like C++ or Java. Its purpose is to serve as the source language for a simple compiler

More information

CS321 Languages and Compiler Design I Winter 2012 Lecture 13

CS321 Languages and Compiler Design I Winter 2012 Lecture 13 STATIC SEMANTICS Static Semantics are those aspects of a program s meaning that can be studied at at compile time (i.e., without running the program). Contrasts with Dynamic Semantics, which describe how

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

On Meaning Preservation of a Calculus of Records

On Meaning Preservation of a Calculus of Records On Meaning Preservation of a Calculus of Records Emily Christiansen and Elena Machkasova Computer Science Discipline University of Minnesota, Morris Morris, MN 56267 chri1101, elenam@morris.umn.edu Abstract

More information

Ruby: Introduction, Basics

Ruby: Introduction, Basics Ruby: Introduction, Basics Computer Science and Engineering College of Engineering The Ohio State University Lecture 4 Ruby vs Java: Similarities Imperative and object-oriented Classes and instances (ie

More information

Lecture Outline. COOL operational semantics. Operational Semantics of Cool. Motivation. Lecture 13. Notation. The rules. Evaluation Rules So Far

Lecture Outline. COOL operational semantics. Operational Semantics of Cool. Motivation. Lecture 13. Notation. The rules. Evaluation Rules So Far Lecture Outline Operational Semantics of Cool Lecture 13 COOL operational semantics Motivation Notation The rules Prof. Aiken CS 143 Lecture 13 1 Prof. Aiken CS 143 Lecture 13 2 Motivation We must specify

More information

Organization of Programming Languages CS3200/5200N. Lecture 11

Organization of Programming Languages CS3200/5200N. Lecture 11 Organization of Programming Languages CS3200/5200N Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.edu Functional vs. Imperative The design of the imperative languages

More information

CONVENTIONAL EXECUTABLE SEMANTICS. Grigore Rosu CS422 Programming Language Semantics

CONVENTIONAL EXECUTABLE SEMANTICS. Grigore Rosu CS422 Programming Language Semantics CONVENTIONAL EXECUTABLE SEMANTICS Grigore Rosu CS422 Programming Language Semantics Conventional Semantic Approaches A language designer should understand the existing design approaches, techniques and

More information

The Untyped Lambda Calculus

The Untyped Lambda Calculus Resources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn

More information

Chapter 3: Describing Syntax and Semantics. Introduction Formal methods of describing syntax (BNF)

Chapter 3: Describing Syntax and Semantics. Introduction Formal methods of describing syntax (BNF) Chapter 3: Describing Syntax and Semantics Introduction Formal methods of describing syntax (BNF) We can analyze syntax of a computer program on two levels: 1. Lexical level 2. Syntactic level Lexical

More information

CS 360: Programming Languages Lecture 12: More Haskell

CS 360: Programming Languages Lecture 12: More Haskell CS 360: Programming Languages Lecture 12: More Haskell Geoffrey Mainland Drexel University Adapted from Brent Yorgey s course Introduction to Haskell. Section 1 Administrivia Administrivia Homework 5 due

More information

Programming Languages Third Edition. Chapter 7 Basic Semantics

Programming Languages Third Edition. Chapter 7 Basic Semantics Programming Languages Third Edition Chapter 7 Basic Semantics Objectives Understand attributes, binding, and semantic functions Understand declarations, blocks, and scope Learn how to construct a symbol

More information

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1) Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 1 Professional Program: Data Administration and Management JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1) WHO

More information

The Untyped Lambda Calculus

The Untyped Lambda Calculus Resources: The slides of this lecture were derived from [Järvi], with permission of the original author, by copy & x = 1 let x = 1 in... paste or by selection, annotation, or rewording. [Järvi] is in turn

More information

Formal Languages and Compilers Lecture V: Parse Trees and Ambiguous Gr

Formal Languages and Compilers Lecture V: Parse Trees and Ambiguous Gr Formal Languages and Compilers Lecture V: Parse Trees and Ambiguous Grammars Free University of Bozen-Bolzano Faculty of Computer Science POS Building, Room: 2.03 artale@inf.unibz.it http://www.inf.unibz.it/

More information

Goals: Define the syntax of a simple imperative language Define a semantics using natural deduction 1

Goals: Define the syntax of a simple imperative language Define a semantics using natural deduction 1 Natural Semantics Goals: Define the syntax of a simple imperative language Define a semantics using natural deduction 1 1 Natural deduction is an instance of first-order logic; that is, it is the formal

More information

Type Checking and Type Equality

Type Checking and Type Equality Type Checking and Type Equality Type systems are the biggest point of variation across programming languages. Even languages that look similar are often greatly different when it comes to their type systems.

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

Programming Languages Third Edition. Chapter 9 Control I Expressions and Statements

Programming Languages Third Edition. Chapter 9 Control I Expressions and Statements Programming Languages Third Edition Chapter 9 Control I Expressions and Statements Objectives Understand expressions Understand conditional statements and guards Understand loops and variation on WHILE

More information

Anatomy of a Compiler. Overview of Semantic Analysis. The Compiler So Far. Why a Separate Semantic Analysis?

Anatomy of a Compiler. Overview of Semantic Analysis. The Compiler So Far. Why a Separate Semantic Analysis? Anatomy of a Compiler Program (character stream) Lexical Analyzer (Scanner) Syntax Analyzer (Parser) Semantic Analysis Parse Tree Intermediate Code Generator Intermediate Code Optimizer Code Generator

More information

Defining Program Syntax. Chapter Two Modern Programming Languages, 2nd ed. 1

Defining Program Syntax. Chapter Two Modern Programming Languages, 2nd ed. 1 Defining Program Syntax Chapter Two Modern Programming Languages, 2nd ed. 1 Syntax And Semantics Programming language syntax: how programs look, their form and structure Syntax is defined using a kind

More information

Polymorphic lambda calculus Princ. of Progr. Languages (and Extended ) The University of Birmingham. c Uday Reddy

Polymorphic lambda calculus Princ. of Progr. Languages (and Extended ) The University of Birmingham. c Uday Reddy 06-02552 Princ. of Progr. Languages (and Extended ) The University of Birmingham Spring Semester 2016-17 School of Computer Science c Uday Reddy2016-17 Handout 6: Polymorphic Type Systems 1. Polymorphic

More information

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

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

More information

The compilation process is driven by the syntactic structure of the program as discovered by the parser

The compilation process is driven by the syntactic structure of the program as discovered by the parser Semantic Analysis The compilation process is driven by the syntactic structure of the program as discovered by the parser Semantic routines: interpret meaning of the program based on its syntactic structure

More information

Ruby: Objects and Dynamic Types

Ruby: Objects and Dynamic Types Ruby: Objects and Dynamic Types Computer Science and Engineering College of Engineering The Ohio State University Lecture 5 Primitive vs Reference Types Recall Java type dichotomy: Primitive: int, float,

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

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

Briefly describe the purpose of the lexical and syntax analysis phases in a compiler.

Briefly describe the purpose of the lexical and syntax analysis phases in a compiler. Name: Midterm Exam PID: This is a closed-book exam; you may not use any tools besides a pen. You have 75 minutes to answer all questions. There are a total of 75 points available. Please write legibly;

More information

Informatica 3 Syntax and Semantics

Informatica 3 Syntax and Semantics Informatica 3 Syntax and Semantics Marcello Restelli 9/15/07 Laurea in Ingegneria Informatica Politecnico di Milano Introduction Introduction to the concepts of syntax and semantics Binding Variables Routines

More information

Fundamental Concepts. Chapter 1

Fundamental Concepts. Chapter 1 Chapter 1 Fundamental Concepts This book is about the mathematical foundations of programming, with a special attention on computing with infinite objects. How can mathematics help in programming? There

More information

Programming with Math and Logic

Programming with Math and Logic .. Programming with Math and Logic an invitation to functional programming Ed Morehouse Wesleyan University The Plan why fp? terms types interfaces The What and Why of Functional Programming Computing

More information

MIT Specifying Languages with Regular Expressions and Context-Free Grammars

MIT Specifying Languages with Regular Expressions and Context-Free Grammars MIT 6.035 Specifying Languages with Regular essions and Context-Free Grammars Martin Rinard Laboratory for Computer Science Massachusetts Institute of Technology Language Definition Problem How to precisely

More information

MIDTERM EXAM (Solutions)

MIDTERM EXAM (Solutions) MIDTERM EXAM (Solutions) Total Score: 100, Max. Score: 83, Min. Score: 26, Avg. Score: 57.3 1. (10 pts.) List all major categories of programming languages, outline their definitive characteristics and

More information

Type Checking and Type Inference

Type Checking and Type Inference Type Checking and Type Inference Principles of Programming Languages CSE 307 1 Types in Programming Languages 2 Static Type Checking 3 Polymorphic Type Inference Version: 1.8 17:20:56 2014/08/25 Compiled

More information

Lists. Michael P. Fourman. February 2, 2010

Lists. Michael P. Fourman. February 2, 2010 Lists Michael P. Fourman February 2, 2010 1 Introduction The list is a fundamental datatype in most functional languages. ML is no exception; list is a built-in ML type constructor. However, to introduce

More information

CSC312 Principles of Programming Languages : Functional Programming Language. Copyright 2006 The McGraw-Hill Companies, Inc.

CSC312 Principles of Programming Languages : Functional Programming Language. Copyright 2006 The McGraw-Hill Companies, Inc. CSC312 Principles of Programming Languages : Functional Programming Language Overview of Functional Languages They emerged in the 1960 s with Lisp Functional programming mirrors mathematical functions:

More information

Binghamton University. CS-140 Fall Problem Solving. Creating a class from scratch

Binghamton University. CS-140 Fall Problem Solving. Creating a class from scratch Problem Solving Creating a class from scratch 1 Recipe for Writing a Class 1. Write the class boilerplate stuff 2. Declare Fields 3. Write Creator(s) 4. Write accessor methods 5. Write mutator methods

More information

Software II: Principles of Programming Languages. Why Expressions?

Software II: Principles of Programming Languages. Why Expressions? Software II: Principles of Programming Languages Lecture 7 Expressions and Assignment Statements Why Expressions? Expressions are the fundamental means of specifying computations in a programming language

More information

Introduction to Functional Programming in Haskell 1 / 56

Introduction to Functional Programming in Haskell 1 / 56 Introduction to Functional Programming in Haskell 1 / 56 Outline Why learn functional programming? The essence of functional programming What is a function? Equational reasoning First-order vs. higher-order

More information

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1)

JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1) Technology & Information Management Instructor: Michael Kremer, Ph.D. Class 4 Professional Program: Data Administration and Management JAVASCRIPT AND JQUERY: AN INTRODUCTION (WEB PROGRAMMING, X452.1) AGENDA

More information

Java: framework overview and in-the-small features

Java: framework overview and in-the-small features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer Java: framework overview and in-the-small features Chair of Software Engineering Carlo A. Furia, Marco Piccioni, Bertrand Meyer

More information

Pointers (continued), arrays and strings

Pointers (continued), arrays and strings Pointers (continued), arrays and strings 1 Last week We have seen pointers, e.g. of type char *p with the operators * and & These are tricky to understand, unless you draw pictures 2 Pointer arithmetic

More information

News and information! Review: Java Programs! Feedback after Lecture 2! Dead-lines for the first two lab assignment have been posted.!

News and information! Review: Java Programs! Feedback after Lecture 2! Dead-lines for the first two lab assignment have been posted.! True object-oriented programming: Dynamic Objects Reference Variables D0010E Object-Oriented Programming and Design Lecture 3 Static Object-Oriented Programming UML" knows-about Eckel: 30-31, 41-46, 107-111,

More information

Object-Oriented Design Lecture 7 CSU 370 Fall 2008 (Pucella) Friday, Oct 3, 2008

Object-Oriented Design Lecture 7 CSU 370 Fall 2008 (Pucella) Friday, Oct 3, 2008 Object-Oriented Design Lecture 7 CSU 370 Fall 2008 (Pucella) Friday, Oct 3, 2008 Type Checking Java Last lecture, we saw different kind of errors, and I indicated that some of those errors can be detected

More information

A New Statement for Selection and Exception Handling in Imperative Languages arxiv: v3 [cs.pl] 24 Aug 2015

A New Statement for Selection and Exception Handling in Imperative Languages arxiv: v3 [cs.pl] 24 Aug 2015 A New Statement for Selection and Exception Handling in Imperative Languages arxiv:1308.4452v3 [cs.pl] 24 Aug 2015 Keehang Kwon Dept. of Computer Engineering, DongA University 840 hadan saha, Busan 604-714,

More information

WELCOME! (download slides and.py files and follow along!) LECTURE 1

WELCOME! (download slides and.py files and follow along!) LECTURE 1 WELCOME! (download slides and.py files and follow along!) 6.0001 LECTURE 1 6.0001 LECTURE 1 1 TODAY course info what is computation python basics mathematical operations python variables and types NOTE:

More information

3.4 Deduction and Evaluation: Tools Conditional-Equational Logic

3.4 Deduction and Evaluation: Tools Conditional-Equational Logic 3.4 Deduction and Evaluation: Tools 3.4.1 Conditional-Equational Logic The general definition of a formal specification from above was based on the existence of a precisely defined semantics for the syntax

More information

Scheme. Functional Programming. Lambda Calculus. CSC 4101: Programming Languages 1. Textbook, Sections , 13.7

Scheme. Functional Programming. Lambda Calculus. CSC 4101: Programming Languages 1. Textbook, Sections , 13.7 Scheme Textbook, Sections 13.1 13.3, 13.7 1 Functional Programming Based on mathematical functions Take argument, return value Only function call, no assignment Functions are first-class values E.g., functions

More information

(Not Quite) Minijava

(Not Quite) Minijava (Not Quite) Minijava CMCS22620, Spring 2004 April 5, 2004 1 Syntax program mainclass classdecl mainclass class identifier { public static void main ( String [] identifier ) block } classdecl class identifier

More information

Decaf Language Reference

Decaf Language Reference Decaf Language Reference Mike Lam, James Madison University Fall 2016 1 Introduction Decaf is an imperative language similar to Java or C, but is greatly simplified compared to those languages. It will

More information

Chapter 3: Propositional Languages

Chapter 3: Propositional Languages Chapter 3: Propositional Languages We define here a general notion of a propositional language. We show how to obtain, as specific cases, various languages for propositional classical logic and some non-classical

More information

Princeton University COS 333: Advanced Programming Techniques A Subset of JavaScript

Princeton University COS 333: Advanced Programming Techniques A Subset of JavaScript Princeton University COS 333: Advanced Programming Techniques A Subset of JavaScript Program Structure function sqr(i) var result; // Otherwise result would be global. result = i * i; //

More information

Chapter 7. Expressions and Assignment Statements

Chapter 7. Expressions and Assignment Statements Chapter 7 Expressions and Assignment Statements Chapter 7 Topics Introduction Arithmetic Expressions Overloaded Operators Type Conversions Relational and Boolean Expressions Short-Circuit Evaluation Assignment

More information

Lecture Notes on Intermediate Representation

Lecture Notes on Intermediate Representation Lecture Notes on Intermediate Representation 15-411: Compiler Design Frank Pfenning Lecture 10 September 26, 2013 1 Introduction In this lecture we discuss the middle end of the compiler. After the source

More information

CS61A Discussion Notes: Week 11: The Metacircular Evaluator By Greg Krimer, with slight modifications by Phoebus Chen (using notes from Todd Segal)

CS61A Discussion Notes: Week 11: The Metacircular Evaluator By Greg Krimer, with slight modifications by Phoebus Chen (using notes from Todd Segal) CS61A Discussion Notes: Week 11: The Metacircular Evaluator By Greg Krimer, with slight modifications by Phoebus Chen (using notes from Todd Segal) What is the Metacircular Evaluator? It is the best part

More information

The syntax and semantics of Beginning Student

The syntax and semantics of Beginning Student The syntax and semantics of Beginning Student Readings: HtDP, Intermezzo 1 (Section 8). We are covering the ideas of section 8, but not the parts of it dealing with section 6/7 material (which will come

More information

The syntax and semantics of Beginning Student

The syntax and semantics of Beginning Student The syntax and semantics of Beginning Student Readings: HtDP, Intermezzo 1 (Section 8). We are covering the ideas of section 8, but not the parts of it dealing with section 6/7 material (which will come

More information

Project 5 - The Meta-Circular Evaluator

Project 5 - The Meta-Circular Evaluator MASSACHVSETTS INSTITVTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science 6.001 Structure and Interpretation of Computer Programs Spring Semester, 2005 Project 5 - The Meta-Circular

More information

Sprite an animation manipulation language Language Reference Manual

Sprite an animation manipulation language Language Reference Manual Sprite an animation manipulation language Language Reference Manual Team Leader Dave Smith Team Members Dan Benamy John Morales Monica Ranadive Table of Contents A. Introduction...3 B. Lexical Conventions...3

More information

Begin at the beginning

Begin at the beginning Begin at the beginning Expressions (Syntax) Exec-time Dynamic Values (Semantics) Compile-time Static Types 1. Programmer enters expression 2. ML checks if expression is well-typed Using a precise set of

More information

Language to Specify Syntax-Guided Synthesis Problems

Language to Specify Syntax-Guided Synthesis Problems Language to Specify Syntax-Guided Synthesis Problems Mukund Raghothaman Abhishek Udupa Saturday 25 th January, 2014 1 Introduction We present a language to specify syntax guided synthesis (SyGuS) problems.

More information

Java Primer 1: Types, Classes and Operators

Java Primer 1: Types, Classes and Operators Java Primer 1 3/18/14 Presentation for use with the textbook Data Structures and Algorithms in Java, 6th edition, by M. T. Goodrich, R. Tamassia, and M. H. Goldwasser, Wiley, 2014 Java Primer 1: Types,

More information

Part II. Hoare Logic and Program Verification. Why specify programs? Specification and Verification. Code Verification. Why verify programs?

Part II. Hoare Logic and Program Verification. Why specify programs? Specification and Verification. Code Verification. Why verify programs? Part II. Hoare Logic and Program Verification Part II. Hoare Logic and Program Verification Dilian Gurov Props: Models: Specs: Method: Tool: safety of data manipulation source code logic assertions Hoare

More information

Parser Tools: lex and yacc-style Parsing

Parser Tools: lex and yacc-style Parsing Parser Tools: lex and yacc-style Parsing Version 6.11.0.6 Scott Owens January 6, 2018 This documentation assumes familiarity with lex and yacc style lexer and parser generators. 1 Contents 1 Lexers 3 1.1

More information

Lecture Notes on Intermediate Representation

Lecture Notes on Intermediate Representation Lecture Notes on Intermediate Representation 15-411: Compiler Design Frank Pfenning Lecture 9 September 24, 2009 1 Introduction In this lecture we discuss the middle end of the compiler. After the source

More information

Type Checking. Outline. General properties of type systems. Types in programming languages. Notation for type rules.

Type Checking. Outline. General properties of type systems. Types in programming languages. Notation for type rules. Outline Type Checking General properties of type systems Types in programming languages Notation for type rules Logical rules of inference Common type rules 2 Static Checking Refers to the compile-time

More information

Values and Variables 1 / 30

Values and Variables 1 / 30 Values and Variables 1 / 30 Values 2 / 30 Computing Computing is any purposeful activity that marries the representation of some dynamic domain with the representation of some dynamic machine that provides

More information

Getting Started with Python

Getting Started with Python Fundamentals of Programming (Python) Getting Started with Python Sina Sajadmanesh Sharif University of Technology Some slides have been adapted from Python Programming: An Introduction to Computer Science

More information

Relational Algebra 1

Relational Algebra 1 Relational Algebra 1 Relational Query Languages v Query languages: Allow manipulation and retrieval of data from a database. v Relational model supports simple, powerful QLs: Strong formal foundation based

More information

Total Test Questions: 43 Levels: Grades Units of Credit:.50

Total Test Questions: 43 Levels: Grades Units of Credit:.50 DESCRIPTION Computer Programming IA introduces students to the fundamentals of computer programming. Students will learn to design, code, and test their own programs while applying mathematical concepts.

More information

Outline. General properties of type systems. Types in programming languages. Notation for type rules. Common type rules. Logical rules of inference

Outline. General properties of type systems. Types in programming languages. Notation for type rules. Common type rules. Logical rules of inference Type Checking Outline General properties of type systems Types in programming languages Notation for type rules Logical rules of inference Common type rules 2 Static Checking Refers to the compile-time

More information

Fall 2017 Discussion 7: October 25, 2017 Solutions. 1 Introduction. 2 Primitives

Fall 2017 Discussion 7: October 25, 2017 Solutions. 1 Introduction. 2 Primitives CS 6A Scheme Fall 207 Discussion 7: October 25, 207 Solutions Introduction In the next part of the course, we will be working with the Scheme programming language. In addition to learning how to write

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

Lexical Analysis. COMP 524, Spring 2014 Bryan Ward

Lexical Analysis. COMP 524, Spring 2014 Bryan Ward Lexical Analysis COMP 524, Spring 2014 Bryan Ward Based in part on slides and notes by J. Erickson, S. Krishnan, B. Brandenburg, S. Olivier, A. Block and others The Big Picture Character Stream Scanner

More information

Overview of the Ruby Language. By Ron Haley

Overview of the Ruby Language. By Ron Haley Overview of the Ruby Language By Ron Haley Outline Ruby About Ruby Installation Basics Ruby Conventions Arrays and Hashes Symbols Control Structures Regular Expressions Class vs. Module Blocks, Procs,

More information

Lecture 3. Lecture

Lecture 3. Lecture True Object-Oriented programming: Dynamic Objects Static Object-Oriented Programming Reference Variables Eckel: 30-31, 41-46, 107-111, 114-115 Riley: 5.1, 5.2 D0010E Object-Oriented Programming and Design

More information

CSCI 3155: Lab Assignment 2

CSCI 3155: Lab Assignment 2 CSCI 3155: Lab Assignment 2 Fall 2017 Checkpoint due Friday, September 15, 2017 Assignment due Friday, September 22, 2017 Learning Goals. The primary learning goals of this lab are to understand the following:

More information

Node.js Training JavaScript. Richard richardrodger.com

Node.js Training JavaScript. Richard richardrodger.com Node.js Training JavaScript Richard Rodger @rjrodger richardrodger.com richard.rodger@nearform.com A New Look at JavaScript Embracing JavaScript JavaScript Data Structures JavaScript Functions Functional

More information

AP Computer Science A

AP Computer Science A 2017 AP Computer Science A Scoring Guidelines College Board, Advanced Placement Program, AP, AP Central, and the acorn logo are registered trademarks of the College Board. AP Central is the official online

More information

Lecture 4. First order logic is a formal notation for mathematics which involves:

Lecture 4. First order logic is a formal notation for mathematics which involves: 0368.4435 Automatic Software Verification April 14, 2015 Lecture 4 Lecturer: Mooly Sagiv Scribe: Nimrod Busany, Yotam Frank Lesson Plan 1. First order logic recap. 2. The SMT decision problem. 3. Basic

More information

Chapter 6 Introduction to Defining Classes

Chapter 6 Introduction to Defining Classes Introduction to Defining Classes Fundamentals of Java: AP Computer Science Essentials, 4th Edition 1 Objectives Design and implement a simple class from user requirements. Organize a program in terms of

More information

G COURSE PLAN ASSISTANT PROFESSOR Regulation: R13 FACULTY DETAILS: Department::

G COURSE PLAN ASSISTANT PROFESSOR Regulation: R13 FACULTY DETAILS: Department:: G COURSE PLAN FACULTY DETAILS: Name of the Faculty:: Designation: Department:: Abhay Kumar ASSOC PROFESSOR CSE COURSE DETAILS Name Of The Programme:: BTech Batch:: 2013 Designation:: ASSOC PROFESSOR Year

More information

Threads and Locks. Chapter Introduction Locks

Threads and Locks. Chapter Introduction Locks Chapter 1 Threads and Locks 1.1 Introduction Java virtual machines support multiple threads of execution. Threads are represented in Java by the Thread class. The only way for a user to create a thread

More information

Semantic Analysis. CSE 307 Principles of Programming Languages Stony Brook University

Semantic Analysis. CSE 307 Principles of Programming Languages Stony Brook University Semantic Analysis CSE 307 Principles of Programming Languages Stony Brook University http://www.cs.stonybrook.edu/~cse307 1 Role of Semantic Analysis Syntax vs. Semantics: syntax concerns the form of a

More information

Compiler construction

Compiler construction Compiler construction Martin Steffen March 13, 2017 Contents 1 Abstract 1 1.1 Types and type checking....................................... 1 1.1.1 Intro...............................................

More information

Lecture Notes on Intermediate Representation

Lecture Notes on Intermediate Representation Lecture Notes on Intermediate Representation 15-411: Compiler Design Frank Pfenning Lecture 10 1 Introduction In this lecture we discuss the middle end of the compiler. After the source has been parsed

More information

Theory of Computer Science. D2.1 Introduction. Theory of Computer Science. D2.2 LOOP Programs. D2.3 Syntactic Sugar. D2.

Theory of Computer Science. D2.1 Introduction. Theory of Computer Science. D2.2 LOOP Programs. D2.3 Syntactic Sugar. D2. Theory of Computer Science April 20, 2016 D2. LOOP- and WHILE-Computability Theory of Computer Science D2. LOOP- and WHILE-Computability Malte Helmert University of Basel April 20, 2016 D2.1 Introduction

More information

JavaScript Programming

JavaScript Programming JavaScript Programming Mendel Rosenblum 1 How do you program in JavaScript? From Wikipedia:... supporting object-oriented, imperative, and functional programming... Mostly programming conventions (i.e.

More information

Lambda Calculus. Type Systems, Lectures 3. Jevgeni Kabanov Tartu,

Lambda Calculus. Type Systems, Lectures 3. Jevgeni Kabanov Tartu, Lambda Calculus Type Systems, Lectures 3 Jevgeni Kabanov Tartu, 13.02.2006 PREVIOUSLY ON TYPE SYSTEMS Arithmetical expressions and Booleans Evaluation semantics Normal forms & Values Getting stuck Safety

More information

Chapter 4. Defining Classes I

Chapter 4. Defining Classes I Chapter 4 Defining Classes I Introduction Classes are the most important language feature that make object oriented programming (OOP) possible Programming in Java consists of dfii defining a number of

More information

JavaScript Basics. Mendel Rosenblum. CS142 Lecture Notes - JavaScript Basics

JavaScript Basics. Mendel Rosenblum. CS142 Lecture Notes - JavaScript Basics JavaScript Basics Mendel Rosenblum 1 What is JavaScript? From Wikipedia:... high-level, dynamic, untyped, and interpreted programming language... is prototype-based with first-class functions,... supporting

More information

Project 5 - The Meta-Circular Evaluator

Project 5 - The Meta-Circular Evaluator MASSACHVSETTS INSTITVTE OF TECHNOLOGY Department of Electrical Engineering and Computer Science 6.001 Structure and Interpretation of Computer Programs Fall Semester, 2005 Project 5 - The Meta-Circular

More information

A Tour of the Cool Support Code

A Tour of the Cool Support Code A Tour of the Cool Support Code 1 Introduction The Cool compiler project provides a number of basic data types to make the task of writing a Cool compiler tractable in the timespan of the course. This

More information

Functional abstraction. What is abstraction? Eating apples. Readings: HtDP, sections Language level: Intermediate Student With Lambda

Functional abstraction. What is abstraction? Eating apples. Readings: HtDP, sections Language level: Intermediate Student With Lambda Functional abstraction Readings: HtDP, sections 19-24. Language level: Intermediate Student With Lambda different order used in lecture section 24 material introduced much earlier sections 22, 23 not covered

More information