BCPL

编程范型 过程式，指令式，结构化 馬丁·理察德 1967年，​57年前[1] 无类型（所有东西都是字） www.cl.cam.ac.uk/~mr10/BCPL.html CPL B语言（间接影响C语言）

概述

Richards試著移除了CPL中最複雜的組成，第一支BCPL compiler在IBM 7094電腦中完成。身為早期程式語言的BCPL，如今已不再廣泛使用，但它的影響卻是深遠的，今日流行的C語言即是參考BCPL所設計[2]。BCPL被认定为第一个[3]，作为BCPL后代语言，C语言使用花括号来表示块结构。

範例

```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. Martin Richards (2003 Computer Pioneer Award). IEEE Computer Society. [2017-11-24]. （原始内容存档于2017-11-24）.
2. ^ Kernighan, Brian W. and Dennis M. Ritchie. The C Programming Language. Bell Telephone Laboratories. 1978: 2. ISBN 0-13-110163-3.
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