|
1 | | - <SECTION> |
2 | | - <NAME>The Elements of Programming</NAME> |
3 | | - <LABEL NAME="sec:elements-of-programming"></LABEL> |
4 | | - <INDEX>programming<SUBINDEX>elements of</SUBINDEX></INDEX> |
| 1 | +<SECTION> |
| 2 | + <NAME>The Elements of Programming</NAME> |
| 3 | + <LABEL NAME="sec:elements-of-programming"></LABEL> |
| 4 | + <INDEX>programming<SUBINDEX>elements of</SUBINDEX></INDEX> |
5 | 5 |
|
6 | | - <SECTIONCONTENT/> |
| 6 | + <SECTIONCONTENT/> |
7 | 7 |
|
8 | | - <TEXT> |
9 | | - A powerful programming language is more than just a means for |
10 | | - instructing a computer to perform tasks. The language also serves as |
11 | | - a framework within which we organize our ideas about processes. Thus, |
12 | | - when we describe a language, we should pay particular attention to the |
13 | | - means that the language provides for combining simple ideas to form |
14 | | - more complex ideas. Every powerful language has three mechanisms for |
15 | | - accomplishing this: |
16 | | - <UL> |
17 | | - <LI> |
18 | | - <B>primitive expressions</B>, which represent the simplest |
19 | | - entities the language is concerned with, |
20 | | - <INDEX>primitive expression</INDEX> |
21 | | - </LI> |
22 | | - <LI> |
23 | | - <B>means of combination</B>, by which compound |
24 | | - elements are built from simpler ones, and |
25 | | - <INDEX>means of combination</INDEX> |
26 | | - <INDEX>combination, means of</INDEX> |
27 | | - </LI> |
28 | | - <LI> |
29 | | - <B>means of abstraction</B>, by |
30 | | - which compound elements can be named and manipulated as units. |
31 | | - <INDEX>means of abstraction</INDEX> |
32 | | - </LI> |
33 | | - </UL> |
34 | | - </TEXT> |
35 | | - <TEXT> |
36 | | - In programming, we deal with two kinds of elements: |
37 | | - <INDEX>procedure</INDEX> |
38 | | - <SPLITINLINE><SCHEME>procedures</SCHEME><JAVASCRIPT>functions</JAVASCRIPT></SPLITINLINE> |
39 | | - and |
40 | | - <INDEX>data</INDEX> |
41 | | - data. (Later we will discover that they are really not so distinct.) |
42 | | - Informally, data is <QUOTE>stuff</QUOTE> that we want to manipulate, and |
43 | | - <SPLITINLINE><SCHEME>procedures</SCHEME><JAVASCRIPT>functions</JAVASCRIPT></SPLITINLINE> |
44 | | - are descriptions of the rules for manipulating the data. |
45 | | - Thus, any powerful programming language should be able to describe |
46 | | - primitive data and primitive |
47 | | - <SPLITINLINE><SCHEME>procedures</SCHEME><JAVASCRIPT>functions</JAVASCRIPT></SPLITINLINE> |
48 | | - and should have methods for |
49 | | - combining and abstracting |
50 | | - <SPLITINLINE><SCHEME>procedures</SCHEME><JAVASCRIPT>functions</JAVASCRIPT></SPLITINLINE> |
51 | | - and data. |
52 | | - <INDEX>programming<SUBINDEX>elements of</SUBINDEX></INDEX> |
53 | | - </TEXT> |
| 8 | + <TEXT> |
| 9 | + A powerful programming language is more than just a means for |
| 10 | + instructing a computer to perform tasks. The language also serves as |
| 11 | + a framework within which we organize our ideas about processes. Thus, |
| 12 | + when we describe a language, we should pay particular attention to the |
| 13 | + means that the language provides for combining simple ideas to form |
| 14 | + more complex ideas. Every powerful language has three mechanisms for |
| 15 | + accomplishing this: |
| 16 | + <UL> |
| 17 | + <LI> |
| 18 | + <B>primitive expressions</B>, which represent the simplest |
| 19 | + entities the language is concerned with, |
| 20 | + <INDEX>primitive expression</INDEX> |
| 21 | + </LI> |
| 22 | + <LI> |
| 23 | + <B>means of combination</B>, by which compound |
| 24 | + elements are built from simpler ones, and |
| 25 | + <INDEX>means of combination</INDEX> |
| 26 | + <INDEX>combination, means of</INDEX> |
| 27 | + </LI> |
| 28 | + <LI> |
| 29 | + <B>means of abstraction</B>, by |
| 30 | + which compound elements can be named and manipulated as units. |
| 31 | + <INDEX>means of abstraction</INDEX> |
| 32 | + </LI> |
| 33 | + </UL> |
| 34 | + </TEXT> |
| 35 | + |
| 36 | + <TEXT> |
| 37 | + In programming, we deal with two kinds of elements: |
| 38 | + <INDEX>procedure</INDEX> |
| 39 | + <SPLITINLINE> |
| 40 | + <SCHEME>procedures</SCHEME> |
| 41 | + <JAVASCRIPT>functions</JAVASCRIPT> |
| 42 | + </SPLITINLINE> |
| 43 | + and |
| 44 | + <INDEX>data</INDEX> |
| 45 | + data. (Later we will discover that they are really not so distinct.) |
| 46 | + Informally, data is <QUOTE>stuff</QUOTE> that we want to manipulate, and |
| 47 | + <SPLITINLINE> |
| 48 | + <SCHEME>procedures</SCHEME> |
| 49 | + <JAVASCRIPT>functions</JAVASCRIPT> |
| 50 | + </SPLITINLINE> |
| 51 | + are descriptions of the rules for manipulating the data. |
| 52 | + Thus, any powerful programming language should be able to describe |
| 53 | + primitive data and primitive |
| 54 | + <SPLITINLINE> |
| 55 | + <SCHEME>procedures</SCHEME> |
| 56 | + <JAVASCRIPT>functions</JAVASCRIPT> |
| 57 | + </SPLITINLINE> |
| 58 | + and should have methods for |
| 59 | + combining and abstracting |
| 60 | + <SPLITINLINE> |
| 61 | + <SCHEME>procedures</SCHEME> |
| 62 | + <JAVASCRIPT>functions</JAVASCRIPT> |
| 63 | + </SPLITINLINE> |
| 64 | + and data. |
| 65 | + <INDEX>programming<SUBINDEX>elements of</SUBINDEX></INDEX> |
| 66 | + </TEXT> |
54 | 67 |
|
55 | | - <TEXT> |
56 | | - In this chapter we will deal only with simple |
57 | | - <INDEX>numerical data</INDEX><INDEX>data<SUBINDEX>numerical</SUBINDEX></INDEX> |
58 | | - numerical data so that |
59 | | - we can focus on the rules for building |
60 | | - <SPLITINLINE><SCHEME>procedures</SCHEME><JAVASCRIPT>functions</JAVASCRIPT></SPLITINLINE>.<FOOTNOTE>The |
61 | | - characterization of numbers as <QUOTE>simple data</QUOTE> |
62 | | - is a barefaced bluff. |
63 | | - In fact, the treatment of numbers is one of the trickiest and most |
64 | | - confusing aspects of any programming language. Some typical issues |
65 | | - involved are these: |
66 | | - <INDEX>integer(s)</INDEX> |
67 | | - <INDEX>real number</INDEX> |
68 | | - <INDEX>number(s)</INDEX> |
69 | | - <INDEX>integer vs.<SPACE/>real number</INDEX> |
70 | | - <SPLIT><SCHEME> |
71 | | - Some computer systems distinguish <EM>integers</EM>, such as 2, from |
72 | | - <EM>real numbers</EM>, such as 2.71. Is the real number 2.00 different |
73 | | - from the integer 2? |
74 | | - Are the arithmetic operations used |
75 | | - for integers the same as the operations used for real numbers? Does 6 |
76 | | - divided by 2 produce 3, or 3.0? |
77 | | - </SCHEME> |
78 | | - </SPLIT> |
79 | | - How large a number can we represent? |
80 | | - How many decimal places of accuracy can we represent? |
81 | | - <SPLIT><SCHEME> |
82 | | - Is the range of |
83 | | - integers the same as the range of real numbers? |
84 | | - </SCHEME></SPLIT> |
85 | | - <INDEX>numerical analysis</INDEX> |
86 | | - <INDEX>roundoff error</INDEX> |
87 | | - <INDEX>truncation error</INDEX> |
88 | | - Above and beyond |
89 | | - these questions, of course, lies a collection of issues concerning |
90 | | - roundoff and truncation errors<EMDASH/>the entire science of numerical |
91 | | - analysis. Since our focus in this book is on large-scale program |
92 | | - design rather than on numerical techniques, we are going to ignore |
93 | | - these problems. The numerical examples in this chapter will exhibit |
94 | | - the usual roundoff behavior that one observes when using arithmetic |
95 | | - operations that preserve a limited number of decimal places of |
96 | | - accuracy in noninteger operations. |
97 | | - <LABEL NAME="foot:number-representation"></LABEL> |
98 | | - </FOOTNOTE> |
99 | | - In later chapters we will see that |
100 | | - these same rules allow us to build |
101 | | - <SPLITINLINE><SCHEME>procedures</SCHEME><JAVASCRIPT>functions</JAVASCRIPT></SPLITINLINE> |
102 | | - to manipulate compound data as well. |
103 | | - </TEXT> |
| 68 | + <TEXT> |
| 69 | + In this chapter we will deal only with simple |
| 70 | + <INDEX>numerical data</INDEX> |
| 71 | + <INDEX>data<SUBINDEX>numerical</SUBINDEX></INDEX> |
| 72 | + numerical data so that |
| 73 | + we can focus on the rules for building |
| 74 | + <SPLITINLINE><SCHEME>procedures</SCHEME><JAVASCRIPT>functions</JAVASCRIPT></SPLITINLINE>.<FOOTNOTE>The |
| 75 | + <LABEL NAME="foot:number-representation"></LABEL> |
| 76 | + characterization of numbers as <QUOTE>simple data</QUOTE> is a barefaced |
| 77 | + bluff. In fact, the treatment of numbers is one of the trickiest and most |
| 78 | + confusing aspects of any programming language. Some typical issues |
| 79 | + involved are these: |
| 80 | + <INDEX>integer(s)</INDEX> |
| 81 | + <INDEX>real number</INDEX> |
| 82 | + <INDEX>number(s)</INDEX> |
| 83 | + <INDEX>integer vs.<SPACE/>real number</INDEX> |
| 84 | + Some computer systems distinguish <EM>integers</EM>, such as 2, |
| 85 | + from <EM>real numbers</EM>, such as 2.71. Is the real number |
| 86 | + 2.00 different from the integer 2? Are the arithmetic operations |
| 87 | + used for integers the same as the operations used for real numbers? |
| 88 | + Does 6 divided by 2 produce 3, or 3.0? How large a number can we |
| 89 | + represent? How many decimal places of accuracy can we represent? |
| 90 | + Is the range of integers the same as the range of real numbers? |
| 91 | + <INDEX>numerical analysis</INDEX> |
| 92 | + <INDEX>roundoff error</INDEX> |
| 93 | + <INDEX>truncation error</INDEX> |
| 94 | + Above and beyond these questions, of course, lies a collection of |
| 95 | + issues concerning roundoff and truncation errors<EMDASH/>the |
| 96 | + entire science of numerical analysis. Since our focus in this |
| 97 | + book is on large-scale program design rather than on numerical |
| 98 | + techniques, we are going to ignore these problems. The numerical |
| 99 | + examples in this chapter will exhibit the usual roundoff behavior |
| 100 | + that one observes when using arithmetic operations that preserve |
| 101 | + a limited number of decimal places of accuracy in noninteger |
| 102 | + operations. |
| 103 | + </FOOTNOTE> |
| 104 | + In later chapters we will see that |
| 105 | + these same rules allow us to build |
| 106 | + <SPLITINLINE> |
| 107 | + <SCHEME>procedures</SCHEME> |
| 108 | + <JAVASCRIPT>functions</JAVASCRIPT> |
| 109 | + </SPLITINLINE> |
| 110 | + to manipulate compound data as well. |
| 111 | + </TEXT> |
104 | 112 |
|
105 | | - <!-- Subsection 1 : Expressions --> |
106 | | - &subsection1.1.1; |
| 113 | + <!-- Subsection 1 : Expressions --> |
| 114 | + &subsection1.1.1; |
107 | 115 |
|
108 | | - <!-- Subsection 2 : Naming and the Environment --> |
109 | | - &subsection1.1.2; |
| 116 | + <!-- Subsection 2 : Naming and the Environment --> |
| 117 | + &subsection1.1.2; |
110 | 118 |
|
111 | | - <!-- Subsection 3 : Evaluating Combinations --> |
112 | | - &subsection1.1.3; |
| 119 | + <!-- Subsection 3 : Evaluating Combinations --> |
| 120 | + &subsection1.1.3; |
113 | 121 |
|
114 | | - <!-- Subsection 4 : Compound Procedures --> |
115 | | - &subsection1.1.4; |
| 122 | + <!-- Subsection 4 : Compound Procedures --> |
| 123 | + &subsection1.1.4; |
116 | 124 |
|
117 | | - <!-- Subsection 5 : The Substitution Model for Procedure Application --> |
118 | | - &subsection1.1.5; |
| 125 | + <!-- Subsection 5 : The Substitution Model for Procedure Application --> |
| 126 | + &subsection1.1.5; |
119 | 127 |
|
120 | | - <!-- Subsection 6 : Conditional Expressions and Predicates --> |
121 | | - &subsection1.1.6; |
| 128 | + <!-- Subsection 6 : Conditional Expressions and Predicates --> |
| 129 | + &subsection1.1.6; |
122 | 130 |
|
123 | | - <!-- Subsection 7 : Example: Square Roots by Newtons Method --> |
124 | | - &subsection1.1.7; |
| 131 | + <!-- Subsection 7 : Example: Square Roots by Newtons Method --> |
| 132 | + &subsection1.1.7; |
125 | 133 |
|
126 | | - <!-- Subsection 8 : Procedures as Black-Box Abstractions --> |
127 | | - &subsection1.1.8; |
128 | | - |
129 | | - </SECTION> |
| 134 | + <!-- Subsection 8 : Procedures as Black-Box Abstractions --> |
| 135 | + &subsection1.1.8; |
| 136 | + |
| 137 | +</SECTION> |
0 commit comments