6-Data%20Types - 6. Data Types 6.1 Introduction Evolution...

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

View Full Document Right Arrow Icon
ICS 313 - Fundamentals of Programming Languages 1 6. Data Types 6.1 Introduction ± Evolution of Data Types ` FORTRAN I (1957) - INTEGER, REAL, arrays ` ` Ada (1983) - User can create a unique type for every category of variables in the problem space and have the system enforce the types ± A descriptor is the collection of the attributes of a variable ± Design Issues for all data types ` What is the syntax of references to variables? ` What operations are defined and how are they specified?
Background image of page 1

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

View Full DocumentRight Arrow Icon
ICS 313 - Fundamentals of Programming Languages 2 6.2 Primitive Data Types ± Those not defined in terms of other data types ± 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 ± 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; some languages allow accuracy specs in code e.g. (Ada) type SPEED is digits 7 range 0.0. .1000.0; type VOLTAGE is delta 0.1 range -12.0. .24.0; ` See book for representation of floating point (p. 223) 6.2 Primitive Data Types (continued) ± representation of floating point
Background image of page 2
ICS 313 - Fundamentals of Programming Languages 3 6.2 Primitive Data Types (continued) ± Decimal ` For business applications (money) ` Store a fixed number of decimal digits (coded) ` Advantage: accuracy ` Disadvantages: limited range, wastes memory ± Boolean ` Could be implemented as bits, but often as bytes ` Advantage: readability ± Character Types ` ASCII character set ` Unicode 6.3 Character String Types ± Values are sequences of characters ± Design issues ` Is it a primitive type or just a special kind of array? ` Is the length of objects static or dynamic? ± Operations ` Assignment ` Comparison (=, >, etc.) ` Catenation ` Substring reference ` Pattern matching
Background image of page 3

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

View Full DocumentRight Arrow Icon
ICS 313 - Fundamentals of Programming Languages 4 6.3 Character String Types (continued) ± Examples ` Pascal ¾ Not primitive; assignment and comparison only (of packed arrays) ` Ada, FORTRAN 90, and BASIC ¾ Somewhat primitive ¾ Assignment, comparison, catenation, substring reference ¾ FORTRAN has an intrinsic for pattern matching ` Ada ¾ ¾ N(2. .4) (substring reference) ` C and C++ ¾ Not primitive ¾ Use char arrays and a library of functions that provide operations ` SNOBOL4 (a string manipulation language) ¾ Primitive ¾ Many operations, including elaborate pattern matching 6.3 Character String Types (continued) ` Perl and JavaScript ¾ Patterns are defined in terms of regular expressions ¾ A very powerful facility! ¾
Background image of page 4
Image of page 5
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 09/15/2010 for the course ICS ics103 taught by Professor Alvi during the Spring '07 term at King Fahd University of Petroleum & Minerals.

Page1 / 19

6-Data%20Types - 6. Data Types 6.1 Introduction Evolution...

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

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