tailieunhanh - Lecture Programming languages (2/e): Chapter 4 - Tucker, Noonan

The vocabulary of a programming language includes a carefully designed set of rules for naming entities- variables, functions, classes, parameters, and so forth. Names of entities also have other properties during the life of a program, such as their scope, visibility, and binding. The study of names in programming languages and their impact on the syntax and semantics of a program is the subject of Chapter 4. | Programming Languages 2nd edition Tucker and Noonan Chapter 4 Names The first step toward wisdom is calling things by their right names. Anon. Chinese Proverb Syntactic Issues Variables Scope Symbol Table Resolving References Dynamic Scoping Visibility Overloading Lifetime Recall that the term binding is an association between an entity (such as a variable) and a property (such as its value). A binding is static if the association occurs before run-time. A binding is dynamic if the association occurs at run-time. Name bindings play a fundamental role. The lifetime of a variable name refers to the time interval during which memory is allocated. Syntactic Issues Lexical rules for names. Collection of reserved words or keywords. Case sensitivity C-like: yes Early languages: no PHP: partly yes, partly no Reserved Words Cannot be used as Identifiers Usually identify major constructs: if while switch Predefined identifiers: ., library routines Variables Basic bindings Name Address Type Value Lifetime L-value - use of a variable name to denote its address. Ex: x = R-value - use of a variable name to denote its value. Ex: = x Some languages support/require explicit dereferencing. Ex: x := !y + 1 // Pointer example: int x,y; int *p; x = *p; *p = y; Scope The scope of a name is the collection of statements which can access the name binding. In static scoping, a name is bound to a collection of statements according to its position in the source program. Most modern languages use static (or lexical) scoping. Two different scopes are either nested or disjoint. In disjoint scopes, same name can be bound to different entities without interference. What constitutes a scope? Algol C Java Ada Package n/a n/a yes yes Class n/a n/a nested yes Function nested yes yes nested Block nested nested nested nested For Loop no no yes automatic The scope in which a name is defined or delared is called its defining scope. A reference to a name is . | Programming Languages 2nd edition Tucker and Noonan Chapter 4 Names The first step toward wisdom is calling things by their right names. Anon. Chinese Proverb Syntactic Issues Variables Scope Symbol Table Resolving References Dynamic Scoping Visibility Overloading Lifetime Recall that the term binding is an association between an entity (such as a variable) and a property (such as its value). A binding is static if the association occurs before run-time. A binding is dynamic if the association occurs at run-time. Name bindings play a fundamental role. The lifetime of a variable name refers to the time interval during which memory is allocated. Syntactic Issues Lexical rules for names. Collection of reserved words or keywords. Case sensitivity C-like: yes Early languages: no PHP: partly yes, partly no Reserved Words Cannot be used as Identifiers Usually identify major constructs: if while switch Predefined identifiers: ., library routines .

TÀI LIỆU MỚI ĐĂNG
crossorigin="anonymous">
Đã 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.