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"
beginandend. 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