[go: up one dir, main page]

跳转到内容

BCPL

维基百科,自由的百科全书
BCPL
编程范型过程式指令式结构化
設計者馬丁·理察德
发行时间1967年,​57年前​(1967[1]
型態系統无类型(所有东西都是
網站www.cl.cam.ac.uk/~mr10/BCPL.html
啟發語言
CPL
影響語言
B语言(间接影响C语言

基本組合編程語言(英語:Basic Combined Programming Language),是一種電腦程式設計語言,源自更早的CPL語言,1967年由劍橋大學的馬丁·理察德所發展出來的[1]

概述

[编辑]

Richards試著移除了CPL中最複雜的組成,第一支BCPL compiler在IBM 7094電腦中完成。身為早期程式語言的BCPL,如今已不再廣泛使用,但它的影響卻是深遠的,今日流行的C語言即是參考BCPL所設計[2]。BCPL被认定为第一个花括号编程语言英语Brace programming language[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)

N個皇后問題

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. ^ 1.0 1.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