Elementary Data Types
Elementary Data Types
Data Objects
A run-time grouping of one or more pieces of
data in a virtual machine
a container for data
it can be
system defined
programmer defined
30-08-2016
Data Types
A data type is a class of data objects together with
a set of operations for creating and manipulating
them.
Specification of a data type:
attributes
valid values
valid operations
30-08-2016
Data Types
Implementation of a data type
storage representation of data object
algorithms of valid operations
Syntactic representation
30-08-2016
Operations
Signature of an operation:
Operations as Mathematical
Functions
Undefined for certain inputs.
Underflow , overflow
Implicit arguments.
Side effects (implicit results).
Self-modification (history sensitive)
30-08-2016
Implementation
Storage representation.
Attributes:
not stored in the runtime storage representation
run time descriptor
implementation of operations
Declarations
Choice of storage representation
Storage management
Polymorphic operations
Type checking
10
30-08-2016
Type Checking
Checking that each operation executed by a
program receives the proper number of
arguments of the proper data type.
Dynamic type checking: run-time (type tags
for data objects)
Static type checking: compile-time
11
12
30-08-2016
13
Strong Typing.
Detect all type errors statically.
A function f , with signature f : S --> R , is
type safe if execution of f cannot generate
a value outside of R .
Type inference.
ML (p.124)
14
30-08-2016
type conversion:
conversion-op : type1 --> type2
15
16
30-08-2016
17
Assignment
Assignment is the basic operation for
changing the binding of a value to a data
object.
In Pascal:
assignment: integer * integer --> void
In C:
assignment:integer * integer-->integer
(p 127)
18
30-08-2016
Initialization
An uninitialized variable: an l-value with no
corresponding r-value.
A serious source of programming errors.
Explicit , implicit.
19
10
30-08-2016
Internationalization
Sorting
Case
Scanning direction
Country-specific data format
Country-specific time format
21
22
11
30-08-2016
23
Number of Components
Fixed size.
Arrays, records , character strings.
Variable size.
Stacks, lists, sets, tables, files, character strings.
Use a pointer data type.
Insert and delete operations.
24
12
30-08-2016
Heterogeneous.
Records, lists.
25
26
13
30-08-2016
27
Multidimensional.
Arrays, record, lists.
28
14
30-08-2016
Whole-data-structure operations.
Addition(arrays), assignment(records),
union(sets).
Insertion/deletion of components.
Creation/deletion of data structures.
29
Includes
storage for the components,
an optional descriptor (for the attributes).
30
15
30-08-2016
Storage Representation
Sequential representation.
Descriptor and components.
Fixed size.
Linked representation.
By pointers.
Variable size.
31
Implementation of Operations
Sequential representation
base-address-plus-offset using an accessing
formula. (p. 146)
Linked representation
following a chain of pointers
32
16
30-08-2016
Storage Management
Access path : its name, a pointer.
Life time of a data object: binding to a
storage location.
Two problems:
garbage
dangling references
33
17
30-08-2016
Type Checking
Existence of a selected component.
Type of a selected component.
35
Data Structures
Vectors and Arrays
Records
Variant Records
Lists
Character Strings
Pointers
Sets
Files
36
18