跳转到内容

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