BCPL

求闻百科,共笔求闻
BCPL
编程范型过程式指令式结构化
设计者马丁·理察德
发行时间1967年,​57年前​(1967[1]
型态系统无类型(所有东西都是
受启发于
CPL
施影响于
B语言(间接影响C语言

基本组合编程语言(英语:Basic Combined Programming Language),是一种电脑程式设计语言,源自更早的CPL语言,1967年由剑桥大学的马丁·理察德所发展出来的[1]

概述

Richards试著移除了CPL中最复杂的组成,第一支BCPL compiler在IBM 7094电脑中完成。身为早期程式语言的BCPL,如今已不再广泛使用,但它的影响却是深远的,今日流行的C语言即是参考BCPL所设计。BCPL是第一支括弧编程语言括弧特征在C语言中随处可见,例如:

LET FUNC foo(a) =  VALOF
{ b := a + 1
  RESULTIS b }

范例

下列是马丁查理斯的BCPL发行中的范例。

打印阶乘

GET "libhdr"

LET start() = VALOF
{ FOR i = 1 TO 5 DO writef("fact(%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("Number of solutions to %i2-queens is %i5*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]. 

参考文献

  • 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