Đang chuẩn bị liên kết để tải về tài liệu:
Lecture Programming languages (2/e): Chapter 5b - Tucker, Noonan

Không đóng trình duyệt đến khi xuất hiện nút TẢI XUỐNG

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 5.1 Type Errors 5.2 Static and Dynamic Typing 5.3 Basic Types 5.4 NonBasic Types 5.5 Recursive Data Types 5.6 Functions as Types 5.7 Type Equivalence 5.8 Subtypes 5.9 Polymorphism and Generics 5.10 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; . employee.age = 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 => 3.375); put(tagged.i); -- error // simulated union type class Value extends Expression { // Value = int intValue | boolean boolValue Type type; int intValue; boolean boolValue; Value(int i) { intValue = i; type = new Type(Type.INTEGER); } Value(boolean b) { boolValue = b; type = new Type(Type.BOOLEAN); } 5.5 Recursive Data Type data Value = IntValue Integer | FloatValue Float | BoolValue Bool | CharValue Char deriving (Eq, Ord, Show) data Expression = Var Variable | Lit Value | Binary Op Expression Expression | Unary Op Expression deriving (Eq, Ord, Show) type Variable = String type Op = String type State = [(Variable, Value)] 5.6 Functions as Types Pascal example: function newton(a, b: real; function f: real): real; . | Programming Languages 2nd edition Tucker and Noonan Chapter 5 Types Types are the leaven of computer programming; they make it digestible. Robin Milner Contents 5.1 Type Errors 5.2 Static and Dynamic Typing 5.3 Basic Types 5.4 NonBasic Types 5.5 Recursive Data Types 5.6 Functions as Types 5.7 Type Equivalence 5.8 Subtypes 5.9 Polymorphism and Generics 5.10 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; . .

Đã 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.