ALGOL 58
外观
编程范型 | 过程式, 指令式, 结构化 |
---|---|
設計者 | Friedrich L. Bauer, Hermann Bottenbruch, Heinz Rutishauser, Klaus Samelson, 約翰·巴科斯, Charles Katz, 艾伦·佩利, Joseph Henry Wegstein |
发行时间 | 1958年 |
受影响于 | |
FORTRAN, IT[1], Plankalkül[2], Superplan, Sequentielle Formelübersetzung[3] | |
影響語言 | |
ALGOL 60,以及类ALGOL语言 |
ALGOL 58(源自英語:ALGOrithmic Language 1958的縮寫),最早稱為“国际代数语言”(英語:International Algebraic Language,縮寫為IAL)[4],它是一種程式語言,是ALGOL家族的第一個成員。它在1958年問世,ALGOL 60即是它的基礎上開發而成。
ALGOL 58介入了复合语句的基础概念[5],但只局限于控制流程,它没有以ALGOL 60中块的那种方式,结合上标识符作用域。
歷史
[编辑]1958年,美国计算机协会(ACM)与联邦德国的应用数学和力学协会(GAMM)成立小组,在苏黎世把他们关于算法表示法的建议[6],综合为一从而形成“国际代数语言”(IAL)[7],后来改称ALGOL 58。
ALGOL 58变体时间线
[编辑]名称 | 年 | 作者 | 国家 | 描述 | 目标CPU |
---|---|---|---|---|---|
ZMMD实现 | 1958 | Friedrich L. Bauer, Heinz Rutishauser, Klaus Samelson, Hermann Bottenbruch | ![]() |
ZMMD是Zürich、München、Mainz、Darmstadt的缩写 | Z22 |
NELIAC | 1958 | 海军电子实验室 | ![]() |
AN/USQ-17 | |
JOVIAL | 1960 | Jules Schwartz | ![]() |
DOD的HOL,先于Ada | 多种 |
BALGOL | 1960 | Joel Merner等人 | ![]() |
Burroughs公司 B220 | |
MAD | 1960 | 密西根大学 | ![]() |
IBM 7090/7094主机,接着在1960年代中期移植到Univac 1108 | |
ALGO | 1961 | Bendix公司 | ![]() |
Bendix G-15 | |
ALGOL 30 | 1962 | 达特茅斯学院的Thomas Eugene Kurtz等人 | ![]() |
后来演进成ALGOL 60 | LGP-30 |
SUBALGOL | 1962 | 斯坦福大学的Bob Braden, Lawrence M. Breed和Roger Moore | ![]() |
BALGOL扩展 | IBM 7090 |
例子代码
[编辑]下面是IAL报告中的例子代码,采用辛普森积分法计算函数F(x)
的积分,函数F(x)
的值由假定存在的函数例程提供:
缩进排版 | IAL报告排版 |
---|---|
procedure Simps(F(), a, b, delta, V);
comment a, b are the min and max, resp. of the points def. interval of integ.
F() is the function to integrated.
delta is the permissible difference between two successive Simpson sums
V is greater than maximum absolute value of F on a, b;
begin
Simps:
Ibar := V×(b-a)
n := 1
h := (b-a)/2
J := h×(F(a)+F(b))
J1: S := 0;
for k := 1 (1) n
S := S+F(a+(2×k-1)×h)
I := J+4×h×S
if (delta < abs(I-Ibar))
begin
Ibar := I
J := (I+J)/4
n := 2×n; h := h/2
go to J1
end
Simps := I/3
return
integer (k, n)
end Simps
|
procedure Simps(F(), a, b, delta, V);
comment a, b are the min and max, resp. of the points def. interval of integ.
F() is the function to integrated.
delta is the permissible difference between two successive Simpson sums
V is greater than maximum absolute value of F on a, b;
begin
Simps: Ibar:= V×(b-a)
n := 1
h := (b-a)/2
J := h×(F(a)+F(b))
J1: S := 0;
for k := 1 (1) n
S := S+F(a+(2×k-1)×h)
I := J+4×h×S
if (delta < abs(I-Ibar))
begin Ibar:= I
J := (I+J)/4
n := 2×n; h := h/2
go to J1 end
Simps := I/3
return
integer (k, n)
end Simps
|
这里在过程主体的复合语句的begin
之后,必须为前面的过程头部中声明的过程名字包含此标识符的恰好一个语句标签,它被用作过程入口点;这里的非实数类型声明integer (k, n)
放在了过程主体的末尾,即就在这个复合语句的end
之前;有标签的复合语句在其end
之后可以跟随着这个标签(尾随;
来分隔于后续字符),它被用来指示这个复合语句的范围。
ALGOL 58对ALGOL 60的影响
[编辑]- IAL介入了参考、出版和硬件语言的三级概念,和有别于自由选择的标识符的有独立表示的“字分界符”的概念(因此没有保留字)。ALGOL 60保持了这种三级概念[8]。
- IAL介入了对赋值(表示左向箭头的
:=
)和等价关系=
的区分,ALGOL 60保持了这种区分。 - IAL和ALGOL 60都允许了具有任意的下方和上方下标边界的数组,并允许用整数表达式定义下标边界。
- IAL和ALGOL 60都允许嵌套的过程定义以及对应标识符的作用域。
- IAL报告采用与ALGOL 60报告几乎相同的术语描述参数替换,将传名调用的可能性保留开放,但不清楚是否当时就认识到了这一点。
- IAL允许数值语句标号,ALGOL 60保持了它。
- IAL在程序内包括非ALGOL代码的可能性,已经在过程参数的上下文中提示到了。
- IAL和ALGOL 60都有“switch指定式”,但无关于C语言及其有关语言的switch语句。
- IAL提议了内联函数形如
f(x) := x / 2
,这在ALGOL 60中被去掉了。 - IAL过程声明为输入和输出参数提供了独立声明,过程可以返回多个值,这种机制在ALGOL 60中被替代为值声明。
- IAL中的变量声明可以位于程序中的任何位置而不必需在过程的开始处。与之相对,在ALGOL 60块中的声明的出现应当先于所有执行语句。
- IAL的
for
语句拥有形式for i := base (increment) limit
,直接模仿了Rutishauser的编程语言Superplan的循环,将其=
替代为:=
,并将其德语关键字Für
替代为英语翻译for
;ALGOL 60将圆括号替代为字分界符step
和until
,使得前者语句转而写为for i := base step increment until limit
。 - IAL的
if
语句没有then
子句或else
子句,它只是用布尔表达式守卫后续语句,进行关系运算的布尔表达式需要用圆括号包围起来。IAL提供了交替语句if either …… or if …… end
来清晰的允许多个条件的测试。二者都被替代为ALGOL的if …… then …… else ……
构造,它介入了悬摆else歧义。 - IAL通过
do
语句提供宏替代,这在ALGOL 60中被去掉了。 - IAL允许在将数组传递给过程时忽略一个或多个数组下标,允许将给一个过程的任何或所有的实参传递给另一个过程。
- IAL的中缀布尔运算符都有相同的优先级。指数通过成对的上下箭头来指示,这去除了嵌套指数的解释混淆;ALGOL 60将成对的箭头替代为一个单一的上箭头,它的功能等价于FORTRAN的
**
。 - IAL报告不明确规定要提供哪些标准函数,模糊的提及了“标准分析函数”。ALGOL 60报告拥有标准函数的更明确列表。
引用
[编辑]- ^ Alan Jay Perlis, With J. W. Smith and H. R. Van Zoeren. Internal Translator (IT): A Compiler for the 650 (PDF). 1957.
- ^ Rojas, Raúl; Hashagen, Ulf. The First Computers: History and Architectures (PDF). MIT Press. 2002: 292. ISBN 978-0262681377.
In his self-righteous way, Zuse blamed the failure of the Plankalkül on others. In the 1993 English version of his autobiography, he wrote (p. 102) "…… only occasionally [I] had the opportunity to have discussions with some of the creators of ALGOL, for example Rutishauser and Bauer. Most of the time we talked past one another. The basic idea of the Plankalkül to systematically construct a programming language from its logical roots, appeared outdated to my partners, or was considered unnecessary ballast."
- ^ Sequential formula translation. Communications of the ACM, Volume 3, Number 2, pages 76-83. February 1960.
- ^ Perlis, A.J. Talk on Computing in the fifties. ACM National Conference. Nashville,. TN. (Transcript in J. A. N. Lee (ed.), Computer Pioneers, IEEE Computer Society Press, Los Alamito, CA, 1995, 545-556). 1981.
- ^ Perlis, A. J.; Samelson, K. Preliminary report: international algebraic language (PDF). Communications of the ACM (New York, NY, USA: ACM). 1958, 1 (12): 8–22 [2023-02-20]. doi:10.1145/377924.594925. (原始内容存档 (PDF)于2023-02-20).
Strings of one or more statements may be combined into a single (compound) statement by enclosing them within the "statement parentheses"
begin
andend
. Single statements are separated by the statement separator ";
". - ^ F. L. Bauer, H. Bottenbruch, H. Rutishauser, K. Samelson. Proposal for a universal language for the description of computing processes (PDF). In: J. W. Carr (ed.), Computer Programming and Artificial Intelligence, University of Michigan Summer School, pages 355-373. 1958.
J. W. Backus, P. H. Diselets, D. C. Evans, R. Goodman, H. Huskey, C. Katz, J. McCarthy, A. Orden, A. J. Perlis, R. Rich, S. Rosen, W. Turanski, J. Wegstein. Proposal for A Programming Language (PDF). ACM Ad Hoc Committee on Languages, From Herbert Stoyan Collection on LISP Programming, Lot X5687.2010, Computer History Museum. 1958. - ^ Perlis, A.J.; Samelson, K. Preliminary report: international algebraic language. Communications of the ACM. 1958, 1 (12): 8–22. doi:10.1145/377924.594925.
- ^ Naur, P (编). Revised report on the Algorithmic Language ALGOL 60 (PDF). International Federation for Information Processing. 1962.
外部連結
[编辑]- Algol 58Archive.today的存檔,存档日期2013-04-15 at the Software Preservation Group (cf. Computer History Museum)
- Algol 58 report from CACM(页面存档备份,存于互联网档案馆) at the Software Preservation Group