ICS 313 1
1
Programming Language Theory Programming Language Theory ICS313 ICS313 Fall 2007 Fall 2007
Nancy E. Reed nreed@hawaii.edu
2
Lecture #7 Lecture #7 Data Types Data Types Primitive Data Types Character String Types User-Defined Ordinal Types Array Types Associative Arrays Record Types Union Types Pointer Types Ref: Chapter 6 in text
3
Memory Layout : Overview Memory Layout : Overview
- Text
Text: : code, constant data
- Data
Data: :
- initialized global & static
variables
- global & static variables – 0
initialized or un-initialized (blank)
- Heap
Heap: : dynamic memory
- Stack
Stack: : dynamic - local variables
xxxxxxxx Text Data Heap Stack Stack
4
Data Types Data Types
Data type - defines
- a collection of data objects and
- a set of predefined operations on those objects
Evolution of data types:
- FORTRAN I (1957) - INTEGER, REAL, arrays
- Ada (1983) - User can create unique types and system enforces the
types
Descriptor - collection of the attributes of a variable Design issues for all data types:
- 1. Syntax of references to variables
- 2. Operations defined and how to specify
What is the mapping to computer representation?
5
Primitive Data Types Primitive Data Types Not defined in terms of other data types
- 1. Integer
- Almost always an exact reflection of the
hardware, so the mapping is trivial
- There may be as many as eight different integer
types in a language (size, signed/unsigned)
- 2. Floating Point
- Model real numbers, but only as approximations
- Languages for scientific use support at least two
floating-point types; sometimes more
- Usually exactly like the hardware, but not always
6
IEEE Floating Point Format Standards IEEE Floating Point Format Standards
Single precision Double precision