1 / 17

Complex Data Types

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?

sharding
Download Presentation

Complex Data Types

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

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 • 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 • 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 • Faster than array subscripts • Elliptical references (COBOL, PL/I) • Operations • Move corresponding

  13. Unions

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

  15. Sets • Pascal, Java

  16. Pointers

  17. Pointers • Operations • 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

More Related