ALGOL 68
ALGOL 68(源自英語:的縮寫),一種指令式程式語言,為ALGOL家族的成員,是官方上的ALGOL 60後繼者。它設計的目標,是提供更廣泛的應用,以及更嚴格的語法定義。
多范式:指令式,过程式,结构化,并发 | |
設計者 | A. van Wijngaarden, B.J. Mailloux, J.E.L. Peck, C.H.A. Koster等人 |
最终报告: 1968年 | |
型態系統 | 静态、强类型、安全,结构化 |
網站 | Revised Report on the Algorithmic Language ALGOL 68 |
主要實作產品 | |
ALGOL 68C, ALGOL 68 Genie(新近[1]), ALGOL 68R, ALGOL 68RS, ALGOL 68S, FLACC, Алгол 68 Ленинград, Odra ALGOL 68 | |
衍生副語言 | |
ALGOL 68/FR (Final Report: 1968), Algol 68/RR (Revised Report: 1973) | |
啟發語言 | |
ALGOL 60, ALGOL Y | |
影響語言 | |
C[3][5]、C++[6]、Bourne shell、KornShell、Bash、Steelman、Ada、Python[7]、Seed7、Mary、S3 |
概論
ALGOL 68由IFIP Working Group 2.1負責設計。1968年12月20日,Working Group 2.1 通過了這個語法規範,並提交IFIP大會通過。它的主要架構者為阿德里安·范·韦恩加登。
代码样例
下面的样例代码实现了埃拉托斯特尼筛法来找到小于等于100的所有素数。ALGOL 68中NIL
是同其他语言中“空指针”的类似者,表示法x OF y
访问STRUCT y
的成员x
。
BEGIN # Algol-68素数筛法,函数式风格 #
MODE LIST = REF NODE;
MODE NODE = STRUCT (INT h, LIST t);
PROC cons = (INT n, LIST l) LIST: HEAP NODE := (n, l);
PROC one to = (INT n) LIST:
(PROC f = (INT m) LIST: (m > n | NIL | cons(m, f(m+1))); f(1));
PROC error = (STRING s) VOID:
(print((newline, " error: ", s, newline)); GOTO stop);
PROC hd = (LIST l) INT: (l IS NIL | error("hd NIL"); SKIP | h OF l);
PROC tl = (LIST l) LIST: (l IS NIL | error("tl NIL"); SKIP | t OF l);
PROC show = (LIST l) VOID:
(l ISNT NIL | print((" ", whole(hd(l), 0))); show(tl(l)) | print(newline));
PROC filter = (PROC (INT) BOOL p, LIST l) LIST:
IF l IS NIL THEN NIL
ELIF p(hd(l)) THEN cons(hd(l), filter(p, tl(l)))
ELSE filter(p, tl(l))
FI;
PROC sieve = (LIST l) LIST:
IF l IS NIL THEN NIL
ELSE
PROC not multiple = (INT n) BOOL: n MOD hd(l) ≠ 0;
cons(hd(l), sieve(filter(not multiple, tl(l))))
FI;
PROC primes = (INT n) LIST: sieve(tl(one to(n)));
show(primes(100))
END
将上述代码保存入文本文件primes.a68
中,并将其中≠
替代为/=
,然后使用ALGOL 68 Genie执行它:
$ a68g -quiet primes.a68
2 3 5 7 11 13 17 19 23 29 31 37 41 43 47 53 59 61 67 71 73 79 83 89 97
註釋
- . [2020-04-22]. (原始内容存档于2020-08-14).
- Dennis Ritchie. (PDF). April 1993 [2007-04-26]. (原始内容 (PDF)存档于2005-06-29).
- Influence on C: types, structures, arrays, pointers and procedures – Dennis Ritchie[2]
- Dennis Ritchie. . June 1988 [2006-09-15]. (原始内容存档于2009-08-27).
- Influence on C: union, structure, syntax and long precision – Dennis Ritchie[4]
- (PDF). Page 12, 2nd paragraph: Algol68 [gave] operator overloading(§3.3.3), references (§3.3.4), and the ability to declare variables anywhere in a block (§3.3.1). March 1993 [2008-05-06]. (原始内容存档 (PDF)于2006-12-10).
- . July 1998 [2007-04-29]. (原始内容存档于2007-05-01).
外部链接
- Revised Report on the Algorithmic Language ALGOL 68(页面存档备份,存于) The official reference for users and implementors of the language (large pdf file, scanned from Algol Bulletin)
- Revised Report on the Algorithmic Language ALGOL 68(页面存档备份,存于) Hyperlinked HTML version of the Revised Report
- A Tutorial on Algol 68, by Andrew S. Tanenbaum, in Computing Surveys, Vol. 8, No. 2, June 1976, with Corrigenda (Vol. 9, No. 3, September 1977)
- Algol 68 Genie – a GNU GPL Algol 68 compiler-interpreter(页面存档备份,存于)
- Open source Algol 68 implementations, on SourceForge(页面存档备份,存于)
- Algol68 Standard Hardware representation (.pdf)(页面存档备份,存于)
- Из истории создания компилятора с Алгол 68(页面存档备份,存于)
- Algol 68 – 25 Years in the USSR(页面存档备份,存于)
- Система программ динамической поддержки для транслятора с Алгол 68
- C history with Algol68 heritage
- McJones, Paul, "Algol 68 implementations and dialects"(页面存档备份,存于), Software Preservation Group, Computer History Museum, 2011-07-05
- Web enabled ALGOL 68 compiler for small experiments
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.