Chapter 7:: Data Types. Mid-Term Test. Mid-Term Test (cont.) Administrative Notes

Similar documents
Lecture Overview. [Scott, chapter 7] [Sebesta, chapter 6]

first class citizens

G Programming Languages Spring 2010 Lecture 6. Robert Grimm, New York University

Chapter 8 :: Subroutines and Control Abstraction. Final Test. Final Test Review Tomorrow

Types II. Hwansoo Han

CSCI312 Principles of Programming Languages!

22c:111 Programming Language Concepts. Fall Types I

Chapter 8 :: Composite Types

Data Types. CSE 307 Principles of Programming Languages Stony Brook University

Organization of Programming Languages (CSE452) Why are there so many programming languages? What makes a language successful?

Data Types. Every program uses data, either explicitly or implicitly to arrive at a result.

CS 3304 Comparative Languages. Lecture 1: Introduction

CS558 Programming Languages

Programming Languages

Programming Languages

CS321 Languages and Compiler Design I Winter 2012 Lecture 13

Lecture 12: Data Types (and Some Leftover ML)

Fundamentals of Programming Languages. Data Types Lecture 07 sl. dr. ing. Ciprian-Bogdan Chirila

LECTURE 18. Control Flow

Semantic Analysis. How to Ensure Type-Safety. What Are Types? Static vs. Dynamic Typing. Type Checking. Last time: CS412/CS413

Types. What is a type?

Data Types. (with Examples In Haskell) COMP 524: Programming Languages Srinivas Krishnan March 22, 2011

Continuations provide a novel way to suspend and reexecute

TYPES, VALUES AND DECLARATIONS

Programming Languages

CSc 520 Principles of Programming Languages. 26 : Control Structures Introduction

Topic IV. Block-structured procedural languages Algol and Pascal. References:

CS 230 Programming Languages

Principles of Programming Languages

G Programming Languages - Fall 2012

Francesco Nidito. Programmazione Avanzata AA 2007/08

Topic IV. Parameters. Chapter 5 of Programming languages: Concepts & constructs by R. Sethi (2ND EDITION). Addison-Wesley, 1996.

Fundamentals of Programming Languages

Chapter 5 Names, Binding, Type Checking and Scopes

MIDTERM EXAMINATION - CS130 - Spring 2003

CS 314 Principles of Programming Languages

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

Topic 9: Type Checking

Topic 9: Type Checking

Question No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given

Programming Languages, Summary CSC419; Odelia Schwartz

Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types. Record Types. Pointer and Reference Types

CS412/CS413. Introduction to Compilers Tim Teitelbaum. Lecture 17: Types and Type-Checking 25 Feb 08

Type systems. Static typing

(Refer Slide Time: 1:36)

CSC 533: Organization of Programming Languages. Spring 2005

MIDTERM EXAMINATION - CS130 - Spring 2005

Types. Chapter Six Modern Programming Languages, 2nd ed. 1

CS 330 Lecture 18. Symbol table. C scope rules. Declarations. Chapter 5 Louden Outline

Programming Languages Third Edition. Chapter 10 Control II Procedures and Environments

Review of the C Programming Language

Chapter 3:: Names, Scopes, and Bindings (cont.)

Chapter 3:: Names, Scopes, and Bindings (cont.)

Chapter 11 :: Functional Languages

Principles of Programming Languages [PLP-2015] Detailed Syllabus

Programming Language Pragmatics

Programming in C++ Prof. Partha Pratim Das Department of Computer Science and Engineering Indian Institute of Technology, Kharagpur

CSc 372. Comparative Programming Languages. 2 : Functional Programming. Department of Computer Science University of Arizona

1 Terminology. 2 Environments and Static Scoping. P. N. Hilfinger. Fall Static Analysis: Scope and Types

Course outline. CSE 341: Programming Languages. Why study programming languages? Course motivation and objectives. 1 lecture: Concepts

An Object Oriented Programming with C

Data Types (cont.) Administrative Issues. Academic Dishonesty. How do we detect plagiarism? Strongly Typed Languages. Type System

Lecture 13: Complex Types and Garbage Collection

Organization of Programming Languages CS3200 / 5200N. Lecture 06

CS558 Programming Languages

CSC 467 Lecture 13-14: Semantic Analysis

1 Lexical Considerations

Concepts Introduced in Chapter 7

Organization of Programming Languages CS320/520N. Lecture 06. Razvan C. Bunescu School of Electrical Engineering and Computer Science

UNIT II Structuring the Data, Computations and Program. Kainjan Sanghavi

CSE 452: Programming Languages. Outline of Today s Lecture. Expressions. Expressions and Control Flow

UNIT I Programming Language Syntax and semantics. Kainjan Sanghavi

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

Motivation for typed languages

Chapter 6 Control Flow. June 9, 2015

Introduction. Primitive Data Types: Integer. Primitive Data Types. ICOM 4036 Programming Languages

Programming Languages

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

Lecture 9: Control Flow

Lecture 13: Expression Evaluation

Properties of an identifier (and the object it represents) may be set at

Concepts Introduced in Chapter 6

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

Type Bindings. Static Type Binding

NOTE: Answer ANY FOUR of the following 6 sections:

Introduction to Programming in C Department of Computer Science and Engineering. Lecture No. #33 Pointer Arithmetic

Page # Expression Evaluation: Outline. CSCI: 4500/6500 Programming Languages. Expression Evaluation: Precedence

Cpt S 122 Data Structures. Course Review Midterm Exam # 2

SE352b: Roadmap. SE352b Software Engineering Design Tools. W3: Programming Paradigms

Lexical Considerations

CSC 326H1F, Fall Programming Languages. What languages do you know? Instructor: Ali Juma. A survey of counted loops: FORTRAN

! Non-determinacy (unspecified order) Maria Hybinette, UGA 2. 1 Landin adding sugar to a language to make it easier to read (for humans)

COS 140: Foundations of Computer Science

C++ (Non for C Programmer) (BT307) 40 Hours

Intermediate Code Generation

CS 565: Programming Languages. Spring 2008 Tu, Th: 16:30-17:45 Room LWSN 1106

Data Types The ML Type System

Short Notes of CS201

VE281 Data Structures and Algorithms. Introduction and Asymptotic Algorithm Analysis

Data Types. Outline. In Text: Chapter 6. What is a type? Primitives Strings Ordinals Arrays Records Sets Pointers 5-1. Chapter 6: Data Types 2

Transcription:

Chapter 7:: Data Types Programming Language Pragmatics Michael L. Scott Administrative Notes Mid-Term Test Thursday, July 27 2006 at 11:30am No lecture before or after the mid-term test You are responsible for material presented in the lectures not necessarily covered in the textbook Administrative Notes Mid-Term Test (cont.) Will cover chapters1-6 Chapter 1: complete Chapter 2: chapter introduction and Section 2.1 Chapter 3: entire chapter except Section 3.5.1, 3.5.2, 3.3.4 and 3.3.5 Chapter 5: entire chapter Chapter 6: chapter introduction & Section 6.1 (complete)

Administrative Notes Assignment One Due date: Friday, July 28 2006 at 1:00pm Submit your assignment in the drop-box located at the Computer Science and Engineering undergraduate office Late assignments are subject to a penalty of 10% each day I may choose to mark only a subset of the assigned questions You must "show your work" where appropriate to obtain full marks Administrative Details Drop Deadline Computer Science Department drop-deadline for the course is July 31 2006 If you wish to drop the course before this deadline will have to petition to "drop late" as far as the registrars office is concerned, the drop deadline has passed (they treated the course as D2 - see registrars office) Of course, the petition will have the support of the department and of myself as well and will be approved under these circumstances Review What are several different ways selection can be achieved? What is the significance of short-circuiting with respect to selection? Why are case constructs important e.g., why not simply use nested if statements? What is a jump table? Why is iteration important? What are some issues we must be aware of with respect to counted loops?

Review What is an iterator? Can a counted loop always be written as a conditional loop? What is recursion? What is required in order for recursion to work? What is tail recursion? What is the significance of tail recursion? Data Types We all have developed an intuitive notion of what types are; what's behind the intuition? collection of values from a "domain" (the denotational approach) internal structure of a bunch of data, described down to the level of a small set of fundamental types (the structural approach) equivalence class of objects (the implementor's approach) collection of well-defined operations that can be applied to objects of that type (the abstraction approach) Data Types What are types good for? implicit context checking - make sure that certain meaningless operations do not occur type checking cannot prevent all meaningless operations It catches enough of them to be useful Polymorphism results when the compiler finds that it doesn't need to know certain things

Data Types STRONG TYPING has become a popular buzz-word like structured programming informally, it means that the language prevents you from applying an operation to data on which it is not appropriate STATIC TYPING means that the compiler can do all the checking at compile time Examples Common Lisp is strongly typed, but not statically typed Ada is statically typed Pascal is almost statically typed Java is strongly typed, with a non-trivial mix of things that can be checked statically and things that have to be checked dynamically Common terms: discrete types countable integer boolean char enumeration subrange Scalar types - one-dimensional discrete real

Composite types: records (unions) arrays strings sets pointers lists files ORTHOGONALITY is a useful goal in the design of a language, particularly its type system A collection of features is orthogonal if there are no restrictions on the ways in which the features can be combined (analogy to vectors) For example Pascal is more orthogonal than Fortran, (because it allows arrays of anything, for instance), but it does not permit variant records as arbitrary fields of other records (for instance) Orthogonality is nice primarily because it makes a language easy to understand, easy to use, and easy to reason about

A TYPE SYSTEM has rules for type equivalence (when are the types of two values the same?) type compatibility (when can a value of type A be used in a context that expects type B?) type inference (what is the type of an expression, given the types of the operands?) Type compatibility / type equivalence Compatibility is the more useful concept, because it tells you what you can DO The terms are often (incorrectly, but we do it too) used interchangeably. Certainly format does not matter: struct { int a, b; } is the same as struct { int a, b; } We certainly want them to be the same as struct { int a; int b; }

Two major approaches: structural equivalence and name equivalence Name equivalence is based on declarations Structural equivalence is based on some notion of meaning behind those declarations Name equivalence is more fashionable these days There are at least two common variants on name equivalence The differences between all these approaches boils down to where you draw the line between important and unimportant differences between type descriptions In all three schemes described in the book, we begin by putting every type description in a standard form that takes care of "obviously unimportant" distinctions like those above Structural equivalence depends on simple comparison of type descriptions substitute out all names expand all the way to built-in types Original types are equivalent if the expanded type descriptions are the same