Changes between Version 5 and Version 6 of Fundamentals
- Timestamp:
- 05/12/23 20:47:03 (3 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
Fundamentals
v5 v6 16 16 == Example Illustrating Scopes and Processes 17 17 18 To understand the static and dynamic nature of scopes and processes, and the relations between them, we consider the (artificial) example code in Fig. 1 . The static scopes in the scope are numbered from 0 to 6.18 To understand the static and dynamic nature of scopes and processes, and the relations between them, we consider the (artificial) example code in Fig. 1(a). The static scopes in the code are numbered from 0 to 6. 19 19 20 || [[Image(scopeCodeExample.png, width=250px)]] || [[Image(staticScopeTree.png, width=250px)]] || [[Image(scopeStateExample.png, width=250px]] || 21 Fig. 1. CIVL-C code skeleton to illustrate scope hierarchy. 20 || [[Image(scopeCodeExample.png, width=250px, valign=top, margin-right=5)]] || \ 21 [[Image(staticScopeTree.png, width=200px, valign=top, margin-left=5, margin-right=5)]] || \ 22 [[Image(scopeStateExample.png, width=275px, valign=top, margin-left=5)]] || 23 Fig. 1. CIVL-C scopes. (a) code skeleton to illustrate scope hierarchy. (b) static scope tree. (c) a state showing dynamic scopes and process call stacks 22 24 23 The static scopes have a tree structure: one scope is a child of another if the first is immediately contained in the second. Scope 0, which is the file scope (or root scope) is the root of this tree. The static scope tree is depicted in Fig. 2 (left). Each scope is identified by its integer ID. Additionally, if the scope happens to be the scope of a function definition, the name of the function is included in this identifier. A node in this tree also shows the variables and functions declared in the scope. For brevity, we omit the proc variables.25 The static scopes have a tree structure: one scope is a child of another if the first is immediately contained in the second. Scope 0, which is the file scope (or root scope) is the root of this tree. The static scope tree is depicted in Fig. 1(b). Each scope is identified by its integer ID. Additionally, if the scope happens to be the scope of a function definition, the name of the function is included in this identifier. A node in this tree also shows the variables and functions declared in the scope. For brevity, we omit the proc variables. 24 26 25 26 We now look at what happens when this program executes. Fig. 2 (right) illustrates a 27 We now look at what happens when this program executes. Fig. 1(c) illustrates a
