# Data Types (cont.) Subset. subtype in Ada. Powerset. set of in Pascal. implementations. CSE 3302 Programming Languages 10/1/2007

Size: px
Start display at page:

Download "Data Types (cont.) Subset. subtype in Ada. Powerset. set of in Pascal. implementations. CSE 3302 Programming Languages 10/1/2007"

## Transcription

1 CSE 3302 Programming Languages Data Types (cont.) Chengkai Li Fall 2007 Subset U = { v v satisfies certain conditions and v V} Ada subtype Example 1 type Digit_Type is range 0..9; subtype IntDigit_Type is integer range 0..9; 1 2 subtype in Ada Example 2 type Disc is (IsInt, IsReal); type IntOrReal (which: Disc) is record case which is when IsInt => i: integer; when IsReal => r: float; end case; end record; subtype IRInt is IntOrReal(IsInt); subtype IRReal is IntOrReal(IsReal); x: IRReal := 2.3; P(U) = { U U U } Example: Pascal set of <ordinal type> Powerset var S: set of ; var S: ; What s the difference? The order isn t significant though unordered, values are distinct 3 4 set of in Pascal implementations var S, T: set of ; S := [1, 2, 3, 5, 7]; T := [1.. 6]; Set operations can be performed on the variables. What are these? T := S*T; If T = [1, 3, 5] then ; x = 3; if x in S then ; if S<=T then ; type students = (Alice, Bob, Charlie, Dave, Eve,...); var CSE3302, CSE3310, whotookboth: set of students; CSE3302 := [ Alice, Bob, Dave ]; CSE3310 := [ Alice, Charlie, Dave, Eve ]; whotookboth := CSE3302 * CSE3310; Alice Bob Charlie Dave Eve CSE CSE Whotookboth (*) (+) ( ) = (=) (<>) (>) (>=) (<) (<=) (in) 5 How about other operations? (membership, intersection, union, count, subsumption, ) 6 1

2 bit operations for set Implementation can be very efficient bit and (&), bit or ( ), bit negation (~), bit xor Hardware support Alternatives? Having Set type is convenient and efficient. If not present, can we use other types as alternatives? Encoding schemes 7 8 f: U V Array and Functions C/C++ Allocated on stack, size statically specified. index type component type typedef int TenIntArray [10]; typedef int IntArray []; [0, ] (C/C++/Java) Ordinal type (Ada/Pascal) TenIntArray x; int y[5]; int z[]={1,2,3,4}; IntArray w={1,2}; IntArray w; //illegal int n =... //from user input int a[n]; //illegal 9 10 Java Ada Allocated on heap, size dynamically specified; Size can be obtained by.length int n =... //from user input int [] x = new int [n]; System.out.println(x.length); size dynamically specified; Set of subscripts type IntToInt is array(integer range <>) of integer; get(n); //from user input x: IntToInt(1..n); for i in x range loop put(x(i)); end loop;

3 Four Categories of Arrays Based on subscript binding and location binding time Static range of subscripts (static), location (static) e.g. FORTRAN 77 Advantage: execution efficiency Fixed stack dynamic range of subscripts (static), location (dynamic). e.g. Pascal, C, C++ Four Categories of Arrays Stack dynamic range of subscripts (dynamic), location (dynamic), immutable once bound e.g. Ada Advantage: flexibility Heap dynamic range of subscript (dynamic), location (dynamic), can be changed e.g. FORTRAN 90 Advantage: maximum flexibility Advantage: space efficiency Multi dimensional arrays Storage C/C++ int x[10][20]; Java int [][] x = new int [10][20]; Ada These two are different type Matric_Type is array(1..10, ) of integer; x(i,j); type Matric_Type is array(1..10) of array ( ) of integer; x(i)(j); row major form x[1,-10],x[1,-9],,x[1,10],x[2,-10],,x[2,10],x[3,-10], column major form x[1,-10],x[2,-10],,x[10,-10],x[1,-9],,x[10,-9],x[1,-8], C/C++ int array_max(int a[][20][10], int size) Java int array_max(int [][][]a) FORTRAN 90 INTEGER, ALLOCATABLE, ARRAY (:,:) :: MAT (Declares MAT to be a dynamic 2-dim array) ALLOCATE (MAT (10, NUMBER_OF_COLS)) (Allocates MAT to have 10 rows and NUMBER_OF_COLS columns) DEALLOCATE MAT (Deallocates MAT s storage) Array Operations Access individual elements The whole array Pascal: A := B FORTRAN: A+B Ada: Array concatenation A&B FORTRAN 90: matrix multiplication, transpose

4 Functions C: int incfn(int x) { return x+1; } typedef int (*IntFunc)(int); // why *? IntFunc inc = incfn; ML: type IntFunc = int -> int; val inc:intfunc = fn x => x+1; Vector, List, Sequence Functional languages: Vectors: like arrays, more flexibility, especially dynamic resizability. Lists: like vectors, can only be accessed by counting down from the first element. Sequences: typically (potentially) infinite Pointer A pointer type is a type in which the range of values consists of memory addresses and a special value, nil (or null) Advantages: Addressing flexibility (address arithmetic, explicit dereferencing and address of, domain type not fixed (void *)) Dynamic storage management Recursive data structures E.g., linked list struct CharListNode { char data; struct CharListNode* next; }; Typedef struct CharListNode* CharList; Alias (with side effect) int *a, *b; a=(int *) malloc(sizeof(int)); *a=2; b=(int *) malloc(sizeof(int)); *b=3; b=a; *b=4; printf( %d\n, *a); Dangling pointers (dangerous) int *a, *b; a= (int *) malloc(sizeof(int)); b=a; free(a); *b=2; printf( %d\n, *b); Garbages (waste of memory) memory leakage int *a; a = (int *) malloc(sizeof(int)); *a=2; a = (int *) malloc(sizeof(int));

5 Type System Type Constructors: Build new data types upon simple data types Type Checking: The translator checks if data types are used correctly. Type Inference: Infer the type of an expression, whose data type is not given explicitly. e.g., x/y Type Equivalence: Compare two types, decide if they are the same. e.g., x/y and z Type Compatibility: Can we use a value of type A in a place that expects type B? Nontrivial with user defined types and anonymous types Strongly Typed Languages Strongly typed: (Ada, ML, Haskell, Java, Pascal) Most data type errors detected at translation time A few checked during execution and runtime error reported (e.g., subscript out of array bounds). Pros: No data corrupting errors can occur during execution. (I.e., no unsafe program can cause data errors.) Efficiency (in translation and execution.) Security/reliability Cons: May reject safe programs (i.e., legal programs is a subset of safe programs.) Burden on programs, may often need to provide explicit type information Weakly typed and untyped languages Weakly typed: C/C++ e.g., interoperability of integers, pointers, arrays. Untyped (dynamically typed) languages: scheme, smalltalk, perl Doesn t necessarily result in data errors. All type checking performed at execution time. May produce runtime errors too frequently. Security vs. flexibility Strongly typed : No data errors caused by unsafe programs. Maximum restrictiveness, static type checking, illegal safe programs, large amount of type information supplied by programmers. Untyped: Runtime errors, no data corruptions. Legal unsafe programs. reduce the amount of type information the programmer must supply Security vs. flexibility Strongly typed : A type system tries to maximize both flexibility and security, where flexibility means: reduce the number of safe illegal programs & reduce the amount of type information the programmer must supply. Flexibility, no explicit typing or static type checking vs. Maximum restrictiveness, static type checking 29 5

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

CSE 3302 Programming Languages Data Types (cont.) Chengkai Li Fall 2007 1 Administrative Issues Midterm Exam (in class) Tuesday, Oct. 16 th Schedule Change HW1 HW1 part1 & HW1 part2 Due at the same time,

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

Every program uses data, either explicitly or implicitly to arrive at a result. Data in a program is collected into data structures, and is manipulated by algorithms. Algorithms + Data Structures = Programs

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

CS 0 Lecture 8 Chapter 5 Louden Outline The symbol table Static scoping vs dynamic scoping Symbol table Dictionary associates names to attributes In general: hash tables, tree and lists (assignment ) can

### CPSC 3740 Programming Languages University of Lethbridge. Data Types

Data Types A data type defines a collection of data values and a set of predefined operations on those values Some languages allow user to define additional types Useful for error detection through type

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

Organization of Programming Languages CS320/520N Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.edu Data Types A data type defines a collection of data objects and

### Chapter 6. Structured Data Types. Topics. Structured Data Types. Vectors and Arrays. Vectors. Vectors: subscripts

Topics Chapter 6 Structured Data Types Vectors Arrays Slices Associative Arrays Records Unions Lists Sets 2 Structured Data Types Virtually all languages have included some mechanisms for creating complex

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

Chapter 6 Topics WEEK E FOUR Data Types Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types Associative Arrays Record Types Union Types Pointer and Reference

### 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

Data Types In Text: Chapter 6 1 Outline What is a type? Primitives Strings Ordinals Arrays Records Sets Pointers Chapter 6: Data Types 2 5-1 Data Types Two components: Set of objects in the type (domain

### Organization of Programming Languages CS3200 / 5200N. Lecture 06

Organization of Programming Languages CS3200 / 5200N Razvan C. Bunescu School of Electrical Engineering and Computer Science bunescu@ohio.edu Data Types A data type defines a collection of data objects

### Data Types In Text: Ch C apter 6 1

Data Types In Text: Chapter 6 1 Outline What is a type? Primitives Strings Ordinals Arrays Records Sets Pointers 2 Data Types Two components: Set of objects in the type (domain of values) Set of applicable

### CSE 452: Programming Languages. Where are we? Types: Intuitive Perspective. Data Types. High-level Programming Languages.

CSE 452: Programming Languages Data Types Where are we? Machine Language High-level Programming Languages Assembly Language Logic Object Oriented Imperative Functional You are here Concepts specification

### CSE 307: Principles of Programming Languages

CSE 307: Principles of Programming Languages Variables and Constants R. Sekar 1 / 22 Topics 2 / 22 Variables and Constants Variables are stored in memory, whereas constants need not be. Value of variables

### Semantics (cont.) Symbol Table. Static Scope. Static Scope. Static Scope. CSE 3302 Programming Languages. Static vs. Dynamic Scope

-2-1 CSE 3302 Programming Languages Semantics (cont.) Smbol Table Smbol Table: maintain bindings. Can be viewed as functions that map names to their attributes. Names SmbolTable Attributes Chengkai Li,

### TYPES, VALUES AND DECLARATIONS

COSC 2P90 TYPES, VALUES AND DECLARATIONS (c) S. Thompson, M. Winters 1 Names, References, Values & Types data items have a value and a type type determines set of operations variables Have an identifier

### Types. 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

### CS 230 Programming Languages

CS 230 Programming Languages 11 / 20 / 2015 Instructor: Michael Eckmann Questions/comments? Chapter 6 Arrays Pointers Today s Topics We all know what arrays are. Design issues Legal types for subscripts

### Attributes, Bindings, and Semantic Functions Declarations, Blocks, Scope, and the Symbol Table Name Resolution and Overloading Allocation, Lifetimes,

Chapter 5 Basic Semantics Attributes, Bindings, and Semantic Functions Declarations, Blocks, Scope, and the Symbol Table Name Resolution and Overloading Allocation, Lifetimes, and the Environment Variables

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

G22.2110-001 Programming Languages Spring 2010 Lecture 6 Robert Grimm, New York University 1 Review Last week Function Languages Lambda Calculus SCHEME review 2 Outline Promises, promises, promises Types,

### 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

### Types II. Hwansoo Han

Types II Hwansoo Han Arrays Most common and important composite data types Homogeneous elements, unlike records Fortran77 requires element type be scalar Elements can be any type (Fortran90, etc.) A mapping

### Chapter 6. Data Types ISBN

Chapter 6 Data Types ISBN 0-321 49362-1 Chapter 6 Topics Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types Associative Arrays Record Types Union Types Pointer

### The Compiler So Far. CSC 4181 Compiler Construction. Semantic Analysis. Beyond Syntax. Goals of a Semantic Analyzer.

The Compiler So Far CSC 4181 Compiler Construction Scanner - Lexical analysis Detects inputs with illegal tokens e.g.: main 5 (); Parser - Syntactic analysis Detects inputs with ill-formed parse trees

### Storage. Outline. Variables and updating. Copy vs. Ref semantics Lifetime. Dangling References Garbage collection

Storage 1 Variables and updating Outline Copy vs. Ref semantics Lifetime Local and global variables Heap variables Persistent variables Dangling References Garbage collection 2 Variables and Updating Variable:

### Chapter 6. Data Types ISBN

Chapter 6 Data Types ISBN 0-321 49362-1 Chapter 6 Topics Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types Associative Arrays Record Types Union Types Pointer

### COSC252: Programming Languages: Basic Semantics: Data Types. Jeremy Bolton, PhD Asst Teaching Professor

COSC252: Programming Languages: Basic Semantics: Data Types Jeremy Bolton, PhD Asst Teaching Professor Copyright 2015 Pearson. All rights reserved. Common Types and Design Concerns Primitive Data Types

### Programming Languages

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

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

CS412/CS413 Introduction to Compilers Tim Teitelbaum Lecture 13: Types and Type-Checking 19 Feb 07 Semantic Analysis Last time: Semantic errors related to scopes Symbol tables Name resolution This lecture:

### CSE 3302 Programming Languages Lecture 5: Control

CSE 3302 Programming Languages Lecture 5: Control (based on the slides by Chengkai Li) Leonidas Fegaras University of Texas at Arlington CSE 3302 L5 Fall 2009 1 Control Control: what gets executed, when,

### Storage. Outline. Variables and Updating. Composite Variables. Storables Lifetime : Programming Languages. Course slides - Storage

Storage 1 Variables and Updating Outline Composite Variables Total and selective updating Array variables Storables Lifetime Local and global variables Heap variables Persistent variables Garbage collection

### 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,

### Topic 9: Type Checking

Recommended Exercises and Readings Topic 9: Type Checking From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 13.17, 13.18, 13.19, 13.20, 13.21, 13.22 Readings: Chapter 13.5, 13.6 and

### Topic 9: Type Checking

Topic 9: Type Checking 1 Recommended Exercises and Readings From Haskell: The craft of functional programming (3 rd Ed.) Exercises: 13.17, 13.18, 13.19, 13.20, 13.21, 13.22 Readings: Chapter 13.5, 13.6

### Chapter 6 part 1. Data Types. (updated based on 11th edition) ISBN

Chapter 6 part 1 Data Types (updated based on 11th edition) ISBN 0-321 49362-1 Chapter 6 Topics Introduction Primitive Data Types Character String Types User-Defined Ordinal Types Array Types Associative

### Chapter 5. Names, Bindings, and Scopes

Chapter 5 Names, Bindings, and Scopes Chapter 5 Topics Introduction Names Variables The Concept of Binding Scope Scope and Lifetime Referencing Environments Named Constants 1-2 Introduction Imperative

### Types and Type Inference

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

### Lecture Overview. [Scott, chapter 7] [Sebesta, chapter 6]

1 Lecture Overview Types 1. Type systems 2. How to think about types 3. The classification of types 4. Type equivalence structural equivalence name equivalence 5. Type compatibility 6. Type inference [Scott,

### CS321 Languages and Compiler Design I. Fall 2013 Week 8: Types Andrew Tolmach Portland State University

CS321 Languages and Compiler Design I Fall 2013 Week 8: Types Andrew Tolmach Portland State University 1 THE TYPE ZOO int x = 17 Z[1023] := 99; double e = 2.81828 type emp = {name: string, age: int} class

### Data Types. Data Types. Introduction. Data Types. Data Types. Data Types. Introduction

Introduction Primitive Composite Structured Abstract Introduction Introduction Data Type is a Collection of Data Objects Possible r-values for a memory cell Set of operations on those objects Descriptor

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

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

### Heap, Variables, References, and Garbage. CS152. Chris Pollett. Oct. 13, 2008.

Heap, Variables, References, and Garbage. CS152. Chris Pollett. Oct. 13, 2008. Outline. Dynamic Allocation. Variables and Constants. Aliases and Problems. Garbage. Introduction. On Wednesday, we were talking

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

SE352b Software Engineering Design Tools W3: Programming Paradigms Feb. 3, 2005 SE352b, ECE,UWO, Hamada Ghenniwa SE352b: Roadmap CASE Tools: Introduction System Programming Tools Programming Paradigms

### Programming Languages

Programming Languages Types CSCI-GA.2110-003 Fall 2011 What is a type? An interpretation of numbers Consists of a set of values The compiler/interpreter defines a mapping of these values onto the underlying

### Types and Type Inference

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

### Principles of Programming Languages

Principles of Programming Languages h"p://www.di.unipi.it/~andrea/dida2ca/plp- 14/ Prof. Andrea Corradini Department of Computer Science, Pisa Lesson 23! Type systems Type safety Type checking Equivalence,

### Chapter 5 Names, Binding, Type Checking and Scopes

Chapter 5 Names, Binding, Type Checking and Scopes Names - We discuss all user-defined names here - Design issues for names: -Maximum length? - Are connector characters allowed? - Are names case sensitive?

### Static Semantics. Winter /3/ Hal Perkins & UW CSE I-1

CSE 401 Compilers Static Semantics Hal Perkins Winter 2009 2/3/2009 2002-09 Hal Perkins & UW CSE I-1 Agenda Static semantics Types Symbol tables General ideas for now; details later for MiniJava project

### 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

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

Data Types CSE 307 Principles of Programming Languages Stony Brook University http://www.cs.stonybrook.edu/~cse307 1 Data Types We all have developed an intuitive notion of what types are; what's behind

### Structuring the Data. Structuring the Data

2017-05-12 Structuring the Data Structuring the Data 2017-05-12 Structuring the Data 1 Why Use (Static, Strong) Types? hide machine representation improves programming style and maintainability consistent

### Note 3. Types. Yunheung Paek. Associate Professor Software Optimizations and Restructuring Lab. Seoul National University

Note 3 Types Yunheung Paek Associate Professor Software Optimizations and Restructuring Lab. Seoul National University Topics Definition of a type Kinds of types Issues on types Type checking Type conversion

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

Programming Languages Third Edition Chapter 10 Control II Procedures and Environments Objectives Understand the nature of procedure definition and activation Understand procedure semantics Learn parameter-passing

### IMPORTANT QUESTIONS IN C FOR THE INTERVIEW

IMPORTANT QUESTIONS IN C FOR THE INTERVIEW 1. What is a header file? Header file is a simple text file which contains prototypes of all in-built functions, predefined variables and symbolic constants.

### Lecture 12: Data Types (and Some Leftover ML)

Lecture 12: Data Types (and Some Leftover ML) COMP 524 Programming Language Concepts Stephen Olivier March 3, 2009 Based on slides by A. Block, notes by N. Fisher, F. Hernandez-Campos, and D. Stotts Goals

### Class Information ANNOUCEMENTS

Class Information ANNOUCEMENTS Third homework due TODAY at 11:59pm. Extension? First project has been posted, due Monday October 23, 11:59pm. Midterm exam: Friday, October 27, in class. Don t forget to

### Types-2. Type Equivalence

Types-2 Type equivalence Structural Name Algol68 Arrays Array addressing User-defined modes Discriminated unions Dereferencing as type conversion 1 Type Equivalence Structural equivalence SE1: a type name

### Design Issues. Subroutines and Control Abstraction. Subroutines and Control Abstraction. CSC 4101: Programming Languages 1. Textbook, Chapter 8

Subroutines and Control Abstraction Textbook, Chapter 8 1 Subroutines and Control Abstraction Mechanisms for process abstraction Single entry (except FORTRAN, PL/I) Caller is suspended Control returns

### Lecture 9: More Lambda Calculus / Types

Lecture 9: More Lambda Calculus / Types CSC 131 Spring, 2019 Kim Bruce Pure Lambda Calculus Terms of pure lambda calculus - M ::= v (M M) λv. M - Impure versions add constants, but not necessary! - Turing-complete

### - M ::= v (M M) λv. M - Impure versions add constants, but not necessary! - Turing-complete. - true = λ u. λ v. u. - false = λ u. λ v.

Pure Lambda Calculus Lecture 9: More Lambda Calculus / Types CSC 131 Spring, 2019 Kim Bruce Terms of pure lambda calculus - M ::= v (M M) λv. M - Impure versions add constants, but not necessary! - Turing-complete

### Programming Languages, Summary CSC419; Odelia Schwartz

Programming Languages, Summary CSC419; Odelia Schwartz Chapter 1 Topics Reasons for Studying Concepts of Programming Languages Programming Domains Language Evaluation Criteria Influences on Language Design

### Software II: Principles of Programming Languages

Software II: Principles of Programming Languages Lecture 6 Data Types Some Basic Definitions A data type defines a collection of data objects and a set of predefined operations on those objects A descriptor

### Programming Methodology

Spring 2009 Variables 2 Topics Components of a variable Name Assignment l value and r value Scope & Life time Arrays Constant variables Programming language constructs 3 types statements blocks procedures/functions

### 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

### For each of the following variables named x, specify whether they are static, stack-dynamic, or heapdynamic:

For each of the following variables named x, specify whether they are static, stack-dynamic, or heapdynamic: a) in C++: int* x = new(int); b) in Java: class book { protected string title; book(string x)

### Chapter 6. Data Types. *modified by Stephanie Schwartz ISBN

Chapter 6 Data Types *modified by Stephanie Schwartz ISBN 0-321 49362-1 Chapter 6 Topics Introduction Primitive Data Types Character String Types Enumeration Types Array Types Associative Arrays Record

### G Programming Languages - Fall 2012

G22.2110-003 Programming Languages - Fall 2012 Lecture 6 Thomas Wies New York University Review Last week Functional Languages Lambda Calculus Scheme Outline Types Sources: PLP, ch. 7 Types What is a type?

### CS558 Programming Languages

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

### 22c:111 Programming Language Concepts. Fall Functions

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

### Chapter 6. Data Types ISBN

Chapter 6 Data Types ISBN 0-321 49362-1 Chapter 6 Topics Introduction Primitive Data Types Character String Types Enumeration Types Array Types Associative Arrays Record Types Tuple Types List Types Union

### CSCI-GA Scripting Languages

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

### COMP 2355 Introduction to Systems Programming

COMP 2355 Introduction to Systems Programming Christian Grothoff christian@grothoff.org http://grothoff.org/christian/ 1 Pointers Pointers denote addresses in memory In C types, the * represents the use

https://lambda.mines.edu A pointer is a value that indicates location in memory. When we change the location the pointer points to, we say we assign the pointer a value. When we look at the data the pointer

### MIDTERM EXAMINATION - CS130 - Spring 2005

MIDTERM EAMINATION - CS130 - Spring 2005 Your full name: Your UCSD ID number: This exam is closed book and closed notes Total number of points in this exam: 231 + 25 extra credit This exam counts for 25%

### CS558 Programming Languages

CS558 Programming Languages Fall 2016 Lecture 4a Andrew Tolmach Portland State University 1994-2016 Pragmatics of Large Values Real machines are very efficient at handling word-size chunks of data (e.g.

### Chapter 8 :: Composite Types

Chapter 8 :: Composite Types Programming Language Pragmatics, Fourth Edition Michael L. Scott Copyright 2016 Elsevier 1 Chapter08_Composite_Types_4e - Tue November 21, 2017 Records (Structures) and Variants

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

CS412/CS413 Introduction to Compilers Tim Teitelbaum Lecture 17: Types and Type-Checking 25 Feb 08 CS 412/413 Spring 2008 Introduction to Compilers 1 What Are Types? Types describe the values possibly

### Final-Term Papers Solved MCQS with Reference

Solved MCQ(S) From FinalTerm Papers BY Arslan Jan 14, 2018 V-U For Updated Files Visit Our Site : Www.VirtualUstaad.blogspot.com Updated. Final-Term Papers Solved MCQS with Reference 1. The syntax of PHP

### CS558 Programming Languages Winter 2018 Lecture 4a. Andrew Tolmach Portland State University

CS558 Programming Languages Winter 2018 Lecture 4a Andrew Tolmach Portland State University 1994-2018 Pragmatics of Large Values Real machines are very efficient at handling word-size chunks of data (e.g.

### CS558 Programming Languages

CS558 Programming Languages Winter 2017 Lecture 7b Andrew Tolmach Portland State University 1994-2017 Values and Types We divide the universe of values according to types A type is a set of values and

### Subprograms. Bilkent University. CS315 Programming Languages Pinar Duygulu

1 Subprograms CS 315 Programming Languages Pinar Duygulu Bilkent University Introduction 2 Two fundamental abstraction facilities Process abstraction Emphasized from early days Data abstraction Emphasized

### Lecture 14. No in-class files today. Homework 7 (due on Wednesday) and Project 3 (due in 10 days) posted. Questions?

Lecture 14 No in-class files today. Homework 7 (due on Wednesday) and Project 3 (due in 10 days) posted. Questions? Friday, February 11 CS 215 Fundamentals of Programming II - Lecture 14 1 Outline Static

### Chapter 8 ( ) Control Abstraction. Subprograms Issues related to subprograms How is control transferred to & from the subprogram?

Control Abstraction Chapter 8 (81 84) Control Abstraction: Subroutines and parameters Programmer defined control structures Subprograms Procedures Functions Coroutines Exception handlers Processes Subprograms

### A data type defines a collection of data objects and a set of predefined operations on those objects

Data Types Introduction A data type defines a collection of data objects and a set of predefined operations on those objects Language selection criterion who well does supported data types match problem

### CS558 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.

### Fundamentals of Programming Languages

Fundamentals of Programming Languages 1. DEFINITIONS... 2 2. BUILT-IN TYPES AND PRIMITIVE TYPES... 3 TYPE COMPATIBILITY... 9 GENERIC TYPES... 14 MONOMORPHIC VERSUS POLYMORPHIC... 16 TYPE IMPLEMENTATION

### INF 212/CS 253 Type Systems. Instructors: Harry Xu Crista Lopes

INF 212/CS 253 Type Systems Instructors: Harry Xu Crista Lopes What is a Data Type? A type is a collection of computational entities that share some common property Programming languages are designed to

### Compiler Construction

Compiler Construction Thomas Noll Software Modeling and Verification Group RWTH Aachen University https://moves.rwth-aachen.de/teaching/ss-16/cc/ Recap: Static Data Structures Outline of Lecture 18 Recap:

### Dynamic Allocation in C

Dynamic Allocation in C C Pointers and Arrays 1 The previous examples involved only targets that were declared as local variables. For serious development, we must also be able to create variables dynamically,

### 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

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

MUHAMMAD FAISAL MIT 4 th Semester Al-Barq Campus (VGJW01) Gujranwala faisalgrw123@gmail.com MEGA File Solved MCQ s For Final TERM EXAMS CS508- Modern Programming Languages Question No: 1 ( Marks: 1 ) -

### Low-Level C Programming. Memory map Pointers Arrays Structures

Low-Level C Programming Memory map Pointers Arrays Structures Memory Map 0x7FFF_FFFF Binaries load at 0x20000 by default Stack start set by binary when started Stack grows downwards You will need one stack

### CSc 520. Principles of Programming Languages 25: Types Introduction

CSc 520 Principles of Programming Languages 25: Types Introduction Christian Collberg Department of Computer Science University of Arizona collberg@cs.arizona.edu Copyright c 2005 Christian Collberg April

### Names, Bindings, Scopes

Names, Bindings, Scopes Variables In imperative l Language: abstractions of von Neumann machine Variables: abstraction of memory cell or cells Sometimes close to machine (e.g., integers), sometimes not

### In Java we have the keyword null, which is the value of an uninitialized reference type

+ More on Pointers + Null pointers In Java we have the keyword null, which is the value of an uninitialized reference type In C we sometimes use NULL, but its just a macro for the integer 0 Pointers are

### 6. Names, Scopes, and Bindings

Copyright (C) R.A. van Engelen, FSU Department of Computer Science, 2000-2004 6. Names, Scopes, and Bindings Overview Names Binding time Object lifetime Object storage management Static allocation Stack

### Concepts Introduced in Chapter 7

Concepts Introduced in Chapter 7 Storage Allocation Strategies Static Stack Heap Activation Records Access to Nonlocal Names Access links followed by Fig. 7.1 EECS 665 Compiler Construction 1 Activation

### Weeks 6&7: Procedures and Parameter Passing

CS320 Principles of Programming Languages Weeks 6&7: Procedures and Parameter Passing Jingke Li Portland State University Fall 2017 PSU CS320 Fall 17 Weeks 6&7: Procedures and Parameter Passing 1 / 45

### UEE1302 (1102) F10 Introduction to Computers and Programming (I)

Computational Intelligence on Automation Lab @ NCTU UEE1302 (1102) F10 Introduction to Computers and Programming (I) Programming Lecture 10 Pointers & Dynamic Arrays (I) Learning Objectives Pointers Data

### Binding and Variables

Binding and Variables 1. DEFINITIONS... 2 2. VARIABLES... 3 3. TYPE... 4 4. SCOPE... 4 5. REFERENCES... 7 6. ROUTINES... 9 7. ALIASING AND OVERLOADING... 10 8. GENERICS AND TEMPLATES... 12 A. Bellaachia