COS 140: Foundations of Computer Science
|
|
- Noel Gilmore
- 5 years ago
- Views:
Transcription
1 COS 140: Foundations of Variables and Primitive Data Types Fall 2017 Copyright c UMaine School of Computing and Information S 1 / 29
2 Homework Reading: Chapter 16 Homework: Exercises at end of chapter Homework due 10/23 Copyright c UMaine School of Computing and Information S 2 / 29
3 What is a variable? What is a variable? Variable attributes Binding In this lecture: imperative/oo languages A variable is an area of memory that: can have a value can have its value changed by the program Different sizes: byte, word, multiple words Copyright c UMaine School of Computing and Information S 3 / 29
4 Variable attributes What is a variable? Variable attributes Binding Name what do we call it? Address where does it live in memory? Type what kind of thing can it hold? Value contents of the variable Scope who can see this variable? Lifetime duration of program, or shorter period? Copyright c UMaine School of Computing and Information S 4 / 29
5 Binding What is a variable? Variable attributes Binding Associates an attriburte value with an attribute Not just value attribute Two types: Static binding: occurs before run-time, not changed afterward Allows compiler to check for errors, but......need information about the binding at compile time Dynamic binding: takes place/is changed at run-time Copyright c UMaine School of Computing and Information S 5 / 29
6 Name length Special names Name: identifier associated variable Same name different variables in different contexts Different names same variable Unnamed variables: access via pointer Copyright c UMaine School of Computing and Information S 6 / 29
7 Name length Special names Strings (symbols) in a symbol table Symbol tables created at compile/interpretation time Associate names with entities (e.g., variables) Copyright c UMaine School of Computing and Information S 7 / 29
8 Name length Special names Which characters to allow? Have to recognize names during lexical analysis no spaces Sometimes special initial character e.g., a letter For enhanced readability, may allow connectors (e.g., -, ), case-sensitivity Copyright c UMaine School of Computing and Information S 8 / 29
9 Length of variable names Name length Special names Names should be meaningful longer names But symbol table should be reasonable size, easy to maintain shorter names BASIC: one letter + optional number Can t complain about the size! Readable for mathematical applications, but not much else Limited number of characters e.g., FORTRAN (6 or 31), C (63 significant) Trades-off readability and wasted space Table maintenance easy, but whatever the size, someone always wants more Unlimited number of characters e.g., Ada, Lisp Complete flexibility, but......potentially great deal of space, hard to maintain Copyright c UMaine School of Computing and Information S 9 / 29
10 Special names Name length Special names Some names not allowed or limited Reserved words can only be used in language-defined context(s) if in C, e.g. Predefined words defined in the language, but can be changed (e.g., Ada, C [libraries]) Keywords special meaning in some contexts, but can be used as a name (e.g.,for in Lisp,if in FORTRAN) Copyright c UMaine School of Computing and Information S 10 / 29
11 Giving variables values construct binds a value to a variable Often, a construct such as: x = a+b x s value is bound to result ofa+b Not algebra: can have: x = x+1 Copyright c UMaine School of Computing and Information S 11 / 29
12 construct examples C, Java, Python... x = x + 1; Pascal x := x + 1 Lisp (setf x (1+ x)) R x <<- x + 1 orx + 1 -> x Smalltalk x x + 1 Forth x 1 + x! COBOL ADD X 1 GIVING X TCL set x x + 1 Copyright c UMaine School of Computing and Information S 12 / 29
13 All data has a type: integer, floating point, etc. Type species size, interpretation, operations for data All variables have a type attribute Depending on language, variables type static or dynamic Determining variable type: Declared somewhere in program (static, explicit) Inferred by compiler/interpreter (static, implicit; dynamic) Copyright c UMaine School of Computing and Information S 13 / 29
14 What are primitive data types? : defined by language Not (usually) defined in terms of other types Building blocks of new types Unstructured/atomic data types (scalars): Integers Floating point numbers Booleans Characters Pointers Structured data types: Strings Arrays Records Copyright c UMaine School of Computing and Information S 14 / 29
15 Integers Integer type represents subset of the integersz(duh) Most common data type You ve seen: sign-magnitude, two s complement Most languages: several sizes (byte, 2 byte, 4 byte...) Can t represent all possible integers in c instead i...j, wherei 0 j For two s complement, withnbits, can represent 2 n n 1 1 E.g., 8 bits can represent (= ) to (= ). Some languages: unsigned integers (C) Copyright c UMaine School of Computing and Information S 15 / 29
16 Floating point numbers Represent subset of real numbersr Usually two sizes Two parts: fraction and exponent E.g.: , exponent101 2 Copyright c UMaine School of Computing and Information S 16 / 29
17 Floating point numbers Represent subset of real numbersr Usually two sizes Two parts: fraction and exponent E.g.: , exponent101 2 Fractional part= = Copyright c UMaine School of Computing and Information S 16 / 29
18 Floating point numbers Represent subset of real numbersr Usually two sizes Two parts: fraction and exponent E.g.: , exponent101 2 Fractional part= = Exponent = 5, so multiply fraction by2 5 Copyright c UMaine School of Computing and Information S 16 / 29
19 Floating point numbers Represent subset of real numbersr Usually two sizes Two parts: fraction and exponent E.g.: , exponent101 2 Fractional part= = Exponent = 5, so multiply fraction by2 5 So number is = Copyright c UMaine School of Computing and Information S 16 / 29
20 Floating point numbers Represent subset of real numbersr Usually two sizes Two parts: fraction and exponent E.g.: , exponent101 2 Fractional part= = Exponent = 5, so multiply fraction by2 5 So number is = Can t represent all numbers accurately e.g.,π, 1 3 Copyright c UMaine School of Computing and Information S 16 / 29
21 Booleans True/false values Good for flags (switches), conditions to be checked Sometimes languages provide as primitive data type If not: 0 is false, everything else true (C) 0,, [], etc., is false, everything else is true (Python) Representation: smallest efficiently-addressable unit (often byte) Copyright c UMaine School of Computing and Information S 17 / 29
22 Characters Character represented as a pattern of 1s and 0s Representations: ASCII 7 bits code; 8-bit variants of this (e.g., ISO ) are the most common codes used E.g.: a = 33, b = 34,...; space = 32 Unicode 16 bits (or longer); accommodates other alphabets and symbols E.g.: - codepoints 47196, 51060; ; EBCDIC 8 bits; old IBM code Copyright c UMaine School of Computing and Information S 18 / 29
23 Strings Sequence of characters: textual data Special operators (e.g., substring, concatenation), special relational operators, sometimes special assignment Lengths: Fixed length: always same size Limited-dynamic can change, but there s a maximum (e.g., C) Length + sequence (often array) of characters Null-terminated sequence of characters Dynamic can change without limit (e.g., Lisp) more flexible, but overhead for allocation/deallocation Copyright c UMaine School of Computing and Information S 19 / 29
24 Arrays Sometimes need to represent groups of related data items (e.g., integers, characters, etc.) An array is a data type that stores homogeneous data in contiguous memory Can be single-dimensional (vectors) or multi-dimensional Use index to find element Value of index doesn t affect time taken to find element random access storage Copyright c UMaine School of Computing and Information S 20 / 29
25 Design issues for Arrays Syntax for array indices e.g.,temperatures(20) or Temperatures[20] Subscripts: what is the lower bound? bounds checking or not? must subscripts be integers? Number of dimensions allowed Usually no real limits C: limits to one dimension, but allows array elements to be themselves arrays Copyright c UMaine School of Computing and Information S 21 / 29
26 Array descriptors What information is needed by the programming language/program about an array? Base address where is the first element Element type Index type doesn t have to be integer for some languages Index lower, upper bounds Number of locations in array Copyright c UMaine School of Computing and Information S 22 / 29
27 Finding address of array element Element location (or address, A) depends on base address (B), index (I), index lower bound (L), and element size (S) A = B +(I L) S Copyright c UMaine School of Computing and Information S 23 / 29
28 Finding address of array element Element location (or address, A) depends on base address (B), index (I), index lower bound (L), and element size (S) A = B +(I L) S Given an array Taxes whose start location is 1024, element type is a long integer (8 bytes), and whose indices start at 0, find location of elementtaxes[15] Array "Taxes" Taxes[0] Taxes[1] Taxes[15] Copyright c UMaine School of Computing and Information S 23 / 29
29 Finding address of array element Element location (or address, A) depends on base address (B), index (I), index lower bound (L), and element size (S) A = B +(I L) S Given an array Taxes whose start location is 1024, element type is a long integer (8 bytes), and whose indices start at 0, find location of elementtaxes[15] Array "Taxes" Taxes[0] Taxes[1] Taxes[15] A = 1024+(15 0) 8 = 1144 Copyright c UMaine School of Computing and Information S 23 / 29
30 Another example Suppose arrayfoo has elements of a type that requires 6 bytes to store, that it begins at location 4096, and that its indices begin at 10. What is the address offoo[201]? Copyright c UMaine School of Computing and Information S 24 / 29
31 Another example Suppose arrayfoo has elements of a type that requires 6 bytes to store, that it begins at location 4096, and that its indices begin at 10. What is the address offoo[201]? Answer: A = B +(I L) S = 4096+(201 10) 6 = 5242 Copyright c UMaine School of Computing and Information S 24 / 29
32 Optimizing address computation Can write expression so static parts can be calculated at compile time and stored in a constant: A = B +(I L) S = B +(I S) (L S) = (I S)+(B L S) constant part Copyright c UMaine School of Computing and Information S 25 / 29
33 Multidimensional arrays Can have more than 1 dimension E.g., array is 2D, 100 entries, 10 rows, 10 columns Indices: [row,column] or [row][column] How to store dimensions? Row-major order: Rows are kept together, elements stored one row after another T: array 1..10, of integers row 1 row 2 row Column-major order: keeps columns together Row-major probably more common Copyright c UMaine School of Computing and Information S 26 / 29
34 Address calculation ArrayTis an 2D array of temperatures taken over a 1-meter grid, 100 m on a side Assume row-major order, float data type (assume 4 bytes), base address fort=2048, indices each start at 0 (so 0..99) What is the address oft[20,15]? Copyright c UMaine School of Computing and Information S 27 / 29
35 Address calculation ArrayTis an 2D array of temperatures taken over a 1-meter grid, 100 m on a side Assume row-major order, float data type (assume 4 bytes), base address fort=2048, indices each start at 0 (so 0..99) What is the address oft[20,15]? First: what is start of row 20? A [20,0] = B +(I L) S = 2048+(20 0) (4 100) = 10,048 Copyright c UMaine School of Computing and Information S 27 / 29
36 Address calculation ArrayTis an 2D array of temperatures taken over a 1-meter grid, 100 m on a side Assume row-major order, float data type (assume 4 bytes), base address fort=2048, indices each start at 0 (so 0..99) What is the address oft[20,15]? First: what is start of row 20? A [20,0] = B +(I L) S = 2048+(20 0) (4 100) = 10,048 Next, find offset of element in row 20 same kind of calculation: A [20,15] = 10,048+(I L) S = 10,048+(15 0) 4 = 10,108 Copyright c UMaine School of Computing and Information S 27 / 29
37 Heterogenous types: Records, structs contain heterogeneous related data E.g., data about employee: name (string), address (string), salary (fixed-point integer), height (float),... Most languages support this type: struct in C,defstruct in Lisp,record in Pascal, etc. Design issues: How are fields selected? How is field checked? Can we assign one structure to another? How to implement e.g., how to find element from selector? (field must have type, offset) Copyright c UMaine School of Computing and Information S 28 / 29
38 Pointers These point to an object: contain its address Used for user-created dynamic variables (from heap) Used for indirect addressing (e.g., C) abstraction of assembly language s indirect addressing mode Can assign to and through them: int a = 3; // integer int* p; // pointer to integer p = &a; // p = a s address *p = 4; // a now = 4 Often used (in C, e.g.) to access array elements int a[100]; // 100-element array of ints int* p = a; // p = addr of a s start (no &) for (int i=0;i<100;i++) { *p = 0; p++; } Copyright c UMaine School of Computing and Information S 29 / 29
COS 140: Foundations of Computer Science
COS 140: Foundations of Computer Science Variables and Primitive Data Types Fall 2017 Introduction 3 What is a variable?......................................................... 3 Variable attributes..........................................................
More informationCPSC 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
More informationNOTE: Answer ANY FOUR of the following 6 sections:
A-PDF MERGER DEMO Philadelphia University Lecturer: Dr. Nadia Y. Yousif Coordinator: Dr. Nadia Y. Yousif Internal Examiner: Dr. Raad Fadhel Examination Paper... Programming Languages Paradigms (750321)
More informationData 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
More informationData Types. (with Examples In Haskell) COMP 524: Programming Languages Srinivas Krishnan March 22, 2011
Data Types (with Examples In Haskell) COMP 524: Programming Languages Srinivas Krishnan March 22, 2011 Based in part on slides and notes by Bjoern 1 Brandenburg, S. Olivier and A. Block. 1 Data Types Hardware-level:
More informationData 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
More informationIntroduction. Primitive Data Types: Integer. Primitive Data Types. ICOM 4036 Programming Languages
ICOM 4036 Programming Languages Primitive Data Types Character String Types User-Defined Ordinal Types Array Types Associative Arrays Record Types Union Types Pointer and Reference Types Data Types This
More information22c: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 informationCS 430 Spring Mike Lam, Professor. Data Types and Type Checking
CS 430 Spring 2015 Mike Lam, Professor Data Types and Type Checking Type Systems Type system Rules about valid types, type compatibility, and how data values can be used Benefits of a robust type system
More informationData 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
More informationTypes. What is a type?
Types What is a type? Type checking Type conversion Aggregates: strings, arrays, structures Enumeration types Subtypes Types, CS314 Fall 01 BGRyder 1 What is a type? A set of values and the valid operations
More informationChapter 6. Data Types
Chapter 6 Data Types Introduction A data type defines a collection of data objects and a set of predefined operations on those objects A descriptor is the collection of the attributes of a variable Copyright
More informationData 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
More informationOrganization 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
More informationChapter 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
More informationIntroduction 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
More informationTypes 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
More informationTYPES, 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
More informationG 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,
More informationCOSC252: 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
More informationCS 3360 Design and Implementation of Programming Languages. Exam 1
1 Spring 2016 (Monday, March 21) Name: CS 3360 Design and Implementation of Programming Languages Exam 1 This test has 18 questions and pages numbered 1 through 6. Reminders This test is closed-notes and
More informationLecture 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,
More informationChapter 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?
More informationChapter 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
More informationCSE 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
More informationCSCI312 Principles of Programming Languages!
CSCI312 Principles of Programming Languages! Chapter 5 Types Xu Liu! ! 5.1!Type Errors! 5.2!Static and Dynamic Typing! 5.3!Basic Types! 5.4!NonBasic Types! 5.5!Recursive Data Types! 5.6!Functions as Types!
More informationCS 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
More informationCS558 Programming Languages
CS558 Programming Languages Winter 2017 Lecture 7b Andrew Tolmach Portland State University 1994-2017 Values and Types We divide the universe of values according to types A type is a set of values and
More informationLecture 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
More informationCS 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
More informationOrganization 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
More informationChapter 5 Names, Bindings, Type Checking, and Scopes
Chapter 5 Names, Bindings, Type Checking, and Scopes 長庚大學資訊工程學系 陳仁暉 助理教授 Tel: (03) 211-8800 Ext: 5990 E-mail: jhchen@mail.cgu.edu.tw URL: http://www.csie.cgu.edu.tw/jhchen All rights reserved. No part
More informationChapter 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
More informationProgramming 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 informationProgramming 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
More informationChapter 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
More informationArray. Prepared By - Rifat Shahriyar
Java More Details Array 2 Arrays A group of variables containing values that all have the same type Arrays are fixed length entities In Java, arrays are objects, so they are considered reference types
More informationCS558 Programming Languages
CS558 Programming Languages Fall 2016 Lecture 7a Andrew Tolmach Portland State University 1994-2016 Values and Types We divide the universe of values according to types A type is a set of values and a
More informationLanguage Reference Manual simplicity
Language Reference Manual simplicity Course: COMS S4115 Professor: Dr. Stephen Edwards TA: Graham Gobieski Date: July 20, 2016 Group members Rui Gu rg2970 Adam Hadar anh2130 Zachary Moffitt znm2104 Suzanna
More informationMIDTERM EXAMINATION - CS130 - Spring 2003
MIDTERM EXAMINATION - CS130 - Spring 2003 Your full name: Your UCSD ID number: This exam is closed book and closed notes Total number of points in this exam: 120 + 10 extra credit This exam counts for
More informationProgrammiersprachen (Programming Languages)
2016-05-13 Preface Programmiersprachen (Programming Languages) coordinates: lecturer: web: usable for: requirements: No. 185.208, VU, 3 ECTS Franz Puntigam http://www.complang.tuwien.ac.at/franz/ps.html
More informationQuestion 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 ) -
More informationCOS 140: Foundations of Computer Science
COS 140: Foundations of Computer Science CPU Organization and Assembly Language Fall 2018 CPU 3 Components of the CPU..................................................... 4 Registers................................................................
More informationG Programming Languages - Fall 2012
G22.2110-003 Programming Languages - Fall 2012 Lecture 2 Thomas Wies New York University Review Last week Programming Languages Overview Syntax and Semantics Grammars and Regular Expressions High-level
More informationlearning objectives learn about variables, their types and their values learn about different number representations
programming basics learning objectives algorithms your software system software hardware learn about variables, their types and their values learn about different number representations learn boolean algebra
More informationLecture 13: Complex Types and Garbage Collection
Lecture 13: Complex Types and Garbage Collection COMP 524 Programming Language Concepts Stephen Olivier March 17, 2009 Based on slides by A. Block, notes by N. Fisher, F. Hernandez-Campos, and D. Stotts
More informationProgramming Languages
Programming Languages Tevfik Koşar Lecture - VIII February 9 th, 2006 1 Roadmap Allocation techniques Static Allocation Stack-based Allocation Heap-based Allocation Scope Rules Static Scopes Dynamic Scopes
More informationCS 314 Principles of Programming Languages
CS 314 Principles of Programming Languages Lecture 15: Review and Functional Programming Zheng (Eddy) Zhang Rutgers University March 19, 2018 Class Information Midterm exam forum open in Sakai. HW4 and
More information1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4. Epic Test Review 5 Epic Test Review 6 Epic Test Review 7 Epic Test Review 8
Epic Test Review 1 Epic Test Review 2 Epic Test Review 3 Epic Test Review 4 Write a line of code that outputs the phase Hello World to the console without creating a new line character. System.out.print(
More informationWeek 3 Lecture 2. Types Constants and Variables
Lecture 2 Types Constants and Variables Types Computers store bits: strings of 0s and 1s Types define how bits are interpreted They can be integers (whole numbers): 1, 2, 3 They can be characters 'a',
More informationSemantic 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:
More informationSE352b: 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
More informationProgramming 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
More informationCS 3360 Design and Implementation of Programming Languages. Exam 1
1 Spring 2017 (Thursday, March 9) Name: CS 3360 Design and Implementation of Programming Languages Exam 1 This test has 8 questions and pages numbered 1 through 7. Reminders This test is closed-notes and
More informationValues 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 informationNames, 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
More informationData Types, Variables and Arrays. OOC 4 th Sem, B Div Prof. Mouna M. Naravani
Data Types, Variables and Arrays OOC 4 th Sem, B Div 2016-17 Prof. Mouna M. Naravani Identifiers in Java Identifiers are the names of variables, methods, classes, packages and interfaces. Identifiers must
More informationProgramming Languages: Lecture 11
1 Programming Languages: Lecture 11 Chapter 9: Subprograms Jinwoo Kim jwkim@jjay.cuny.edu Chapter 9 Topics 2 Introduction Fundamentals of Subprograms Design Issues for Subprograms Local Referencing Environments
More informationConcepts of Programming Languages
Concepts of Programming Languages Lecture 1 - Introduction Patrick Donnelly Montana State University Spring 2014 Patrick Donnelly (Montana State University) Concepts of Programming Languages Spring 2014
More informationFor 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)
More informationProgram Fundamentals
Program Fundamentals /* HelloWorld.java * The classic Hello, world! program */ class HelloWorld { public static void main (String[ ] args) { System.out.println( Hello, world! ); } } /* HelloWorld.java
More informationLecture Notes on Programming Languages
Lecture Notes on Programming Languages 37 Lecture 04: Data Types and Variables All programming languages provide data types. A data type describes a set of data values and a set of predefined operations
More informationBM214E Object Oriented Programming Lecture 4
BM214E Object Oriented Programming Lecture 4 Computer Numbers Integers (byte, short, int, long) whole numbers exact relatively limited in magnitude (~10 19 ) Floating Point (float, double) fractional often
More informationNumber Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur Number Representation
Number Systems Prof. Indranil Sen Gupta Dept. of Computer Science & Engg. Indian Institute of Technology Kharagpur 1 Number Representation 2 1 Topics to be Discussed How are numeric data items actually
More informationFinal-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
More informationCSC 533: Organization of Programming Languages. Spring 2005
CSC 533: Organization of Programming Languages Spring 2005 Language features and issues variables & bindings data types primitive complex/structured expressions & assignments control structures subprograms
More informationChapter 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
More informationTOPIC 2 INTRODUCTION TO JAVA AND DR JAVA
1 TOPIC 2 INTRODUCTION TO JAVA AND DR JAVA Notes adapted from Introduction to Computing and Programming with Java: A Multimedia Approach by M. Guzdial and B. Ericson, and instructor materials prepared
More informationDerived and abstract data types. TDT4205 Lecture 15
1 Derived and abstract data types TDT4205 Lecture 15 2 Where we were We ve looked at static semantics for primitive types and how it relates to type checking We ve hinted at derived types using a multidimensional
More informationEMBEDDED SYSTEMS PROGRAMMING Language Basics
EMBEDDED SYSTEMS PROGRAMMING 2015-16 Language Basics "The tower of Babel" by Pieter Bruegel the Elder Kunsthistorisches Museum, Vienna (PROGRAMMING) LANGUAGES ABOUT THE LANGUAGES C (1972) Designed to replace
More informationHow to declare an array in C?
Introduction An array is a collection of data that holds fixed number of values of same type. It is also known as a set. An array is a data type. Representation of a large number of homogeneous values.
More informationType Bindings. Static Type Binding
Type Bindings Two key issues in binding (or associating) a type to an identifier: How is type binding specified? When does the type binding take place? N. Meng, S. Arthur 1 Static Type Binding An explicit
More informationExample. program sort; var a : array[0..10] of integer; procedure readarray; : function partition (y, z :integer) :integer; var i, j,x, v :integer; :
Runtime Environment Relationship between names and data objects (of target machine) Allocation & de-allocation is managed by run time support package Each execution of a procedure is an activation of the
More informationFull file at
Java Programming: From Problem Analysis to Program Design, 3 rd Edition 2-1 Chapter 2 Basic Elements of Java At a Glance Instructor s Manual Table of Contents Overview Objectives s Quick Quizzes Class
More informationProperties of an identifier (and the object it represents) may be set at
Properties of an identifier (and the object it represents) may be set at Compile-time These are static properties as they do not change during execution. Examples include the type of a variable, the value
More informationProgramming Lecture 3
Programming Lecture 3 Expressions (Chapter 3) Primitive types Aside: Context Free Grammars Constants, variables Identifiers Variable declarations Arithmetic expressions Operator precedence Assignment statements
More informationCS558 Programming Languages. Winter 2013 Lecture 3
CS558 Programming Languages Winter 2013 Lecture 3 1 NAMES AND BINDING One essential part of being a high-level language is having convenient names for things: variables constants types functions etc. classes
More informationFOR Loop. FOR Loop has three parts:initialization,condition,increment. Syntax. for(initialization;condition;increment){ body;
CLASSROOM SESSION Loops in C Loops are used to repeat the execution of statement or blocks There are two types of loops 1.Entry Controlled For and While 2. Exit Controlled Do while FOR Loop FOR Loop has
More informationHANDLING NONLOCAL REFERENCES
SYMBOL TABLE A symbol table is a data structure kept by a translator that allows it to keep track of each declared name and its binding. Assume for now that each name is unique within its local scope.
More information9/7/17. Outline. Name, Scope and Binding. Names. Introduction. Names (continued) Names (continued) In Text: Chapter 5
Outline Name, Scope and Binding In Text: Chapter 5 Names Variable Binding Type bindings, type conversion Storage bindings and lifetime Scope Lifetime vs. Scope Referencing Environments N. Meng, S. Arthur
More informationLECTURE 18. Control Flow
LECTURE 18 Control Flow CONTROL FLOW Sequencing: the execution of statements and evaluation of expressions is usually in the order in which they appear in a program text. Selection (or alternation): a
More informationVARIABLES AND TYPES CITS1001
VARIABLES AND TYPES CITS1001 Scope of this lecture Types in Java the eight primitive types the unlimited number of object types Values and References The Golden Rule Primitive types Every piece of data
More informationThe Warhol Language Reference Manual
The Warhol Language Reference Manual Martina Atabong maa2247 Charvinia Neblett cdn2118 Samuel Nnodim son2105 Catherine Wes ciw2109 Sarina Xie sx2166 Introduction Warhol is a functional and imperative programming
More informationTopic 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
More informationTopic 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
More informationChapter 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
More informationSt. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad
St. MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad-00 014 Subject: PPL Class : CSE III 1 P a g e DEPARTMENT COMPUTER SCIENCE AND ENGINEERING S No QUESTION Blooms Course taxonomy level Outcomes UNIT-I
More informationCOMP2121: Microprocessors and Interfacing. Number Systems
COMP2121: Microprocessors and Interfacing Number Systems http://www.cse.unsw.edu.au/~cs2121 Lecturer: Hui Wu Session 2, 2017 1 1 Overview Positional notation Decimal, hexadecimal, octal and binary Converting
More information>B<82. 2Soft ware. C Language manual. Copyright COSMIC Software 1999, 2001 All rights reserved.
>B
More informationZheng-Liang Lu Java Programming 45 / 79
1 class Lecture2 { 2 3 "Elementray Programming" 4 5 } 6 7 / References 8 [1] Ch. 2 in YDL 9 [2] Ch. 2 and 3 in Sharan 10 [3] Ch. 2 in HS 11 / Zheng-Liang Lu Java Programming 45 / 79 Example Given a radius
More informationContinuations provide a novel way to suspend and reexecute
Continuations provide a novel way to suspend and reexecute computations. 2. ML ( Meta Language ) Strong, compile-time type checking. Types are determined by inference rather than declaration. Naturally
More informationOrganization of Programming Languages (CSE452) Why are there so many programming languages? What makes a language successful?
Organization of Programming Languages (CSE452) Instructor: Dr. B. Cheng Fall 2004 1 Why are there so many programming languages? Evolution -- we've learned better ways of doing things over time Socio-economic
More informationCS112 Lecture: Primitive Types, Operators, Strings
CS112 Lecture: Primitive Types, Operators, Strings Last revised 1/24/06 Objectives: 1. To explain the fundamental distinction between primitive types and reference types, and to introduce the Java primitive
More informationExample: Haskell algebraic data types (1)
Example: Haskell algebraic data types (1) Type declaration: data Number = Exact Int Inexact Float Set of values: Each Number value consists of a tag, together with either an Integer variant (if the tag
More informationPython Input, output and variables. Lecture 23 COMPSCI111/111G SS 2018
Python Input, output and variables Lecture 23 COMPSCI111/111G SS 2018 1 Today s lecture What is Python? Displaying text on screen using print() Variables Numbers and basic arithmetic Getting input from
More informationComputing Seminar Introduction Oct
Computing Seminar Introduction Oct 6 2010 Outline today Programming/computing basics terminology, high level concepts (variables, control flow, input/output) Before next week... Make sure you can login
More informationMIDTERM 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%
More informationPython Input, output and variables
Today s lecture Python Input, output and variables Lecture 22 COMPSCI111/111G SS 2016! What is Python?! Displaying text on screen using print()! Variables! Numbers and basic arithmetic! Getting input from
More informationJAVA Programming Fundamentals
Chapter 4 JAVA Programming Fundamentals By: Deepak Bhinde PGT Comp.Sc. JAVA character set Character set is a set of valid characters that a language can recognize. It may be any letter, digit or any symbol
More informationInformatica 3 Marcello Restelli
Informatica 3 Marcello Restelli 9/15/07 Laurea in Ingegneria Informatica Politecnico di Milano Operational Semantics We describe the semantics of a programming language by means of an abstract semantic
More information