A powerful programming language is more than just a means for instructing a
computer to perform tasks. The language also serves as a framework within
which we organize our ideas about processes. Thus, when we describe a
language, we should pay particular attention to the means that the language
provides for combining simple ideas to form more complex ideas. Every powerful
language has three mechanisms for accomplishing this:
一门强大的程序设计语言不仅仅是指挥计算机执行任务的工具,它同时也是一个框架,让我们在其中组织自己对计算过程的思想。因此,在描述一门语言时,我们应当特别关注该语言提供的将简单概念组合为复杂概念的方法。每一门强大的语言都具备完成这一目标的三种机制:
primitive expressions,
which represent the simplest entities the language is concerned with,
基本表达式(primitive expressions)——代表语言所关注的最简单的实体,
means of combination,
by which compound elements are built from simpler ones, and
组合的方法(means of combination)——由此将较简单的元素复合为更复杂的元素,以及
means of abstraction,
by which compound elements can be named and manipulated as units.
抽象的方法(means of abstraction)——由此对复合元素命名,并将其作为整体加以操纵。
In programming, we deal with two kinds of elements: procedures and data. (Later
we will discover that they are really not so distinct.) Informally, data is
“stuff” that we want to manipulate, and procedures are descriptions of the
rules for manipulating the data. Thus, any powerful programming language
should be able to describe primitive data and primitive procedures and should
have methods for combining and abstracting procedures and data.
在程序设计中,我们处理的是两类元素:过程 (procedure) 与数据。(稍后我们将会发现,两者之间的界限其实并不那么分明。)非正式地说,数据是我们希望操纵的“东西”,而过程则是描述操纵数据之规则的说明。因此,任何强大的程序设计语言都应能描述基本数据和基本过程,并应具备组合和抽象过程与数据的方法。
In this chapter we will deal only with simple numerical data so that we can
focus on the rules for building procedures. In later chapters we will see that these
same rules allow us to build procedures to manipulate compound data as well.
本章我们只处理简单的数值数据,以便将注意力集中在构造过程的规则上。在后续各章中,我们将看到同样的规则也使我们能够构造操纵复合数据的过程。