BCPL
外觀
編程範型 | 過程式,指令式,結構化 |
---|---|
設計者 | 馬丁·理察德 |
面市時間 | 1967年[1] |
型態系統 | 無類型(所有東西都是字) |
網站 | www |
啟發語言 | |
CPL | |
影響語言 | |
B語言(間接影響C語言) |
基本組合編程語言(英語:Basic Combined Programming Language),是一種電腦程式設計語言,源自更早的CPL語言,1967年由劍橋大學的馬丁·理察德所發展出來的[1] 。
概述
[編輯]Richards試著移除了CPL中最複雜的組成,第一支BCPL compiler在IBM 7094電腦中完成。身為早期程式語言的BCPL,如今已不再廣泛使用,但它的影響卻是深遠的,今日流行的C語言即是參考BCPL所設計[2]。BCPL被認定為第一個花括號程式語言[3],作為BCPL後代語言,C語言使用花括號來表示塊結構。
範例
[編輯]下列是馬丁查理斯的BCPL發行中的範例。
列印階乘:
GET "LIBHDR"
LET START() = VALOF $(
FOR I = 1 TO 5 DO
WRITEF("%N! = %I4*N", I, FACT(I))
RESULTIS 0
$)
AND FACT(N) = N = 0 -> 1, N * FACT(N - 1)
GET "LIBHDR"
GLOBAL $(
COUNT: 200
ALL: 201
$)
LET TRY(LD, ROW, RD) BE
TEST ROW = ALL THEN
COUNT := COUNT + 1
ELSE $(
LET POSS = ALL & ~(LD | ROW | RD)
UNTIL POSS = 0 DO $(
LET P = POSS & -POSS
POSS := POSS - P
TRY(LD + P << 1, ROW + P, RD + P >> 1)
$)
$)
LET START() = VALOF $(
ALL := 1
FOR I = 1 TO 12 DO $(
COUNT := 0
TRY(0, 0, 0)
WRITEF("%I2-QUEENS PROBLEM HAS %I5 SOLUTIONS*N", I, COUNT)
ALL := 2 * ALL + 1
$)
RESULTIS 0
$)
引用
[編輯]- ^ 1.0 1.1 Martin Richards (2003 Computer Pioneer Award). IEEE Computer Society. [2017-11-24]. (原始內容存檔於2017-11-24).
- ^ Kernighan, Brian W. and Dennis M. Ritchie. The C Programming Language. Bell Telephone Laboratories. 1978: 2. ISBN 0-13-110163-3.
- ^ The BCPL Cintsys and Cintpos User Guide, 2.1.4 Section brackets (PDF).
Historically BCPL used the symbols
$(
and$)
to bracket commands and declarations. These symbols are called section brackets and are allowed to be followed by tags composed of letters, digits, dots and underlines. A tagged closing section bracket is forced to match with its corresponding open section bracket by the automatic insertion of extra closing brackets. Use of this mechanism is no longer recommended since it often leads to obscure programming errors. BCPL has been extended to allow all untagged section brackets to be replaced by{
and}
as appropriate.
參考文獻
[編輯]- Martin Richards, The BCPL Reference Manual (Memorandum M-352, Project MAC, Cambridge, July, 1967)
- Martin Richards, BCPL - a tool for compiler writing and systems programming (Proceedings of the Spring Joint Computer Conference, Vol 34, pp 557-566, 1969)
- Martin Richards, Arthur Evans, Robert F. Mabee, The BCPL Reference Manual (MAC TR-141, Project MAC, Cambridge, 1974)
- Martin Richards, C. Whitby-Strevens, BCPL, the language and its compiler (Cambridge University Press, 1980) ISBN 0-521-28681-6