TAILIEUCHUNG - Lecture Programming languages (2/e): Chapter 5b - Tucker, Noonan

A language's types denote the kinds of values that programs can manipulate: simple types, structured types, and more complex types. This chapter presents the following content: Recursive data types, functions as types, type equivalence, subtypes, polymorphism and generics, programmer-defined types. | Programming Languages 2nd edition Tucker and Noonan Chapter 5 Types Types are the leaven of computer programming; they make it digestible. Robin Milner Contents Type Errors Static and Dynamic Typing Basic Types NonBasic Types Recursive Data Types Functions as Types Type Equivalence Subtypes Polymorphism and Generics Programmer-Defined Types Strings Now so fundamental, directly supported. In C, a string is a 1D array with the string value terminated by a NUL character (value = 0). In Java, Perl, Python, a string variable can hold an unbounded number of characters. Libraries of string operations and functions. Structures Analogous to a tuple in mathematics Collection of elements of different types Used first in Cobol, PL/I Absent from Fortran, Algol 60 Common to Pascal-like, C-like languages Omitted from Java as redundant struct employeeType { int id; char name[25]; int age; float salary; char dept; }; struct employeeType employee; . = 45; Unions C: union Pascal: case-variant record Logically: multiple views of same storage Useful in some systems applications type union = record case b : boolean of true : (i : integer); false : (r : real); end; var tagged : union; begin tagged := (b => false, r => ); put(); -- error // simulated union type class Value extends Expression { // Value = int intValue

TỪ KHÓA LIÊN QUAN
Đã phát hiện trình chặn quảng cáo AdBlock
Trang web này phụ thuộc vào doanh thu từ số lần hiển thị quảng cáo để tồn tại. Vui lòng tắt trình chặn quảng cáo của bạn hoặc tạm dừng tính năng chặn quảng cáo cho trang web này.