Presentation is loading. Please wait.

Presentation is loading. Please wait.

Complex Data Types One very important measure of the “goodness” of a PL is the capability of its data types to model the problem space variables Design.

Similar presentations


Presentation on theme: "Complex Data Types One very important measure of the “goodness” of a PL is the capability of its data types to model the problem space variables Design."— Presentation transcript:

1 Complex Data Types One very important measure of the “goodness” of a PL is the capability of its data types to model the problem space variables Design issues for all data types what is the syntax of references to variables? what operations are defined and how are they specified? Compilers use descriptors to maintain information about instances of types in a program actually part of the symbol table what’s needed in descriptor depends on particular type when the descriptor is needed depends on the kind of type checking required static, compile time only dynamic, run-time as well

2 Primitive types Numeric Boolean Character strings Ordinal

3 Numeric Types Range and Precision Integer Real Decimal

4 Boolean

5 Character string

6 Character String Issues
Primitive or not Snobol, Java primitive Ada, F77, F90, Basic “somewhat” primitive Pascal, C, C++ not primitive Static or dynamic Or limited length dynamic Operations

7 Strings (continued) Evaluation Implementation aid to writability
as a primitive type with static length, they are inexpensive to provide--why not have them? dynamic length is nice, but is it worth the expense? Implementation static length - compile-time descriptor limited dynamic length - may need a run-time descriptor for length (but not in C and C++) dynamic length - need run-time descriptor; allocation/deallocation is the biggest problem

8 Ordinal Enumeration Subrange

9 Arrays

10 Arrays Definition Mapping Memory allocation Slices Associative arrays
Row major or column major Memory allocation Static Fixed stack dynamic Stack dynamic Heap dynamic Slices Associative arrays Operations

11 Records

12 Records Definition Mapping Operations Faster than array subscripts
Elliptical references (COBOL, PL/I) Operations Move corresponding

13 Unions

14 Unions Definition Type checking? Useful but dangerous Not in Java
Ada yes, others no Useful but dangerous

15 Sets Pascal, Java

16 Pointers

17 Pointers Operations Dynamic storage management or indirect addressing?
Assignment and dereferencing Dynamic storage management or indirect addressing? Scope/lifetime of pointers and associated dynamic objects? Problems Dangling references, lost objects Storage management Reference counts, garbage collection Java allows only references Implicit deallocation


Download ppt "Complex Data Types One very important measure of the “goodness” of a PL is the capability of its data types to model the problem space variables Design."

Similar presentations


Ads by Google