Feb20 - CSE262: Programming Languages Instructor: Dr. Liang...

Info iconThis preview shows pages 1–11. Sign up to view the full content.

View Full Document Right Arrow Icon
CSE262: Programming Languages Instructor: Dr. Liang Cheng Department of Computer Science and Engineering Lehigh University February 20, 2007
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Instructor: Dr. Liang Cheng CSE262: Programming Languages 02/20/07 Outline ± Recap ± Ordinal types and array types ± Pointer types and record types ± Introduction to Perl ± Summary and homework
Background image of page 2
Instructor: Dr. Liang Cheng CSE262: Programming Languages 02/20/07 Ordinal Types ± An ordinal type is one in which the range of possible values can be easily associated with the set of positive integers ± Example ± Primitive: integer , char , boolean in Java ± User-defined: enumeration and subrange ± Primitive data types ± Character string types ± User-defined ordinal types
Background image of page 3

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Instructor: Dr. Liang Cheng CSE262: Programming Languages 02/20/07 Array Definition ± An aggregate of homogeneous data elements ± Syntax of indexing ± FORTRAN, PL/I, Ada use parentheses ± Most other languages use brackets ± Semantic of indexing ± Row-major and column-major order ± Array types ± Record types ± Union types ± Pointer types
Background image of page 4
Instructor: Dr. Liang Cheng CSE262: Programming Languages 02/20/07 Design Issues ± A[ i ][ j ][ k ] 1. What types are legal for subscripts? 2. What is the maximum number of subscripts? 3. Are subscripting expressions in element references range checked? 4. When are subscript ranges bound? 5. When does allocation take place? 6. Can/how array objects be initialized? 7. Are any kind of slices allowed? ± Array types ± Record types ± Union types ± Pointer types
Background image of page 5

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Instructor: Dr. Liang Cheng CSE262: Programming Languages 02/20/07 Data Types ± Primitive data types ± Character string types ± User-defined ordinal types ± Array types ± Pointer types ± Record types ± Union types
Background image of page 6
Instructor: Dr. Liang Cheng CSE262: Programming Languages 02/20/07 Pointers ± A pointer type is one in which the variables have a range of values that consists of memory addresses and a special value, nil. ± Defined using a type operator ± * in C/C++ and access in Ada ± int* a; ± Array types ± Record types ± Union types ± Pointer types
Background image of page 7

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Instructor: Dr. Liang Cheng CSE262: Programming Languages 02/20/07 Pointer Operations A reference to ptr yields 7080; A dereferenced reference to ptr yields 206 e.g., assignment operation j = *ptr; ± Array types ± Record types ± Union types ± Pointer types ± i The address-of operation of variable i yields 7080; set ptr value to the address of a variable i via e.g., assignment operation ptr = &i;
Background image of page 8
Instructor: Dr. Liang Cheng CSE262: Programming Languages 02/20/07 More Operations ± C and C++ can do address arithmetic in restricted forms, e.g.: float stuff[100]; float* p; p = stuff; *(p+5) is equivalent to stuff[5] and p[5] *(p+i) is equivalent to stuff[i] and p[i] ± Array types ± Record types ± Union types ± Pointer types
Background image of page 9

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Instructor: Dr. Liang Cheng CSE262: Programming Languages
Background image of page 10
Image of page 11
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 08/06/2008 for the course CSE 262 taught by Professor Cheng during the Spring '07 term at Lehigh University .

Page1 / 37

Feb20 - CSE262: Programming Languages Instructor: Dr. Liang...

This preview shows document pages 1 - 11. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online