6data-representation_Nov01

6data-representation_Nov01 - CSci 5106: Programming...

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

View Full Document Right Arrow Icon

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

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: CSci 5106: Programming Languages Data Representation Gopalan Nadathur Department of Computer Science and Engineering University of Minnesota Lectures in Fall 2010 Gopalan Nadathur Data Representation The Object of Study In many programming situations, we need to handle data objects of arbitrary degrees of complexity For example, consider a person record: person dob day in year int year int name first name string last name string Id No string . . . Imperative programming languages provide mechanisms for constructing representations of such objects: representations for primitive kinds of values operators for composing simpler representations to yield more complex ones We will look at these and their use in representing values Gopalan Nadathur Data Representation Data Representation versus Data Object These concepts are distinct and should be recognized as such: The same object may have different representations day in year integer (counting days) structure containing month and day in month Representations may allow more operations than are meaningful on the object E.g., integers can be multiplied but day in year cannot Representations need to be interpreted to yield an object E.g., we need some external process to extract Feb 29 (or March 1) from the integer 60 Gopalan Nadathur Data Representation Realizing Data Objects The eventual desire is to allow programmers to deal with data objects rather than representations This is realized in two steps (IMPLEMENTATION) provide mechanisms for describing data representations E.g. we provide the means for representing the notion of day in year (ABSTRACTION) provide mechanisms for hiding the (inessential and obscuring) details of the representation Thus, we allow access to day in year only through specifically meaningful operations like month , day , etc In particular, we do not allow manipulation directly through integer or record operations For now, we deal only with the first part through data representation; data abstraction is the topic of Chapter 6 Gopalan Nadathur Data Representation The Role of Types Data representations are classified according to the following Sets of permitted values Sets of operations permitted on these values Each category under such a classification is referred to as a type Such a categorization is useful in determining appropriateness of expressions and also in the construction of new types Two relevant operations concerning types defining new types classifying cells (variables) according to the data they can hold Abstract data types provide a similar classification at the level of data objects Gopalan Nadathur Data Representation Type Related Operations Defining New Types Programming languages typically have mechanisms for constructing new types E.g. in Pascal there is an array type constructor : array [ h index-type i ] of h element-type i Type declarations then allow names to be associated with such...
View Full Document

This document was uploaded on 05/06/2011.

Page1 / 15

6data-representation_Nov01 - CSci 5106: Programming...

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

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