
BCPL(Basic Combined Programming Language),是一种电脑程式设计语言,1966年由剑桥大学的马丁·理察斯(Martin Richards)所发展出来的。
身为早期编程语言的BCPL,如今已不再广泛使用,但它的影响却是深远的,今日流行的C语言即是参考BCPL所设计。BCPL是第一支使用括号语言,括号特征在C语言中随处可见,例如
LET FUNC foo(a) = VALOF
{ b := a + 1
RESULTIS b }
for (int i = 0; i < 10; i++)
{
printf("%d", i);
doTask(i);
}
BCPL又源自更早的CPL(Combined Programming Language)语言。Richards试着移除了CPL中最复杂的组成,第一支BCPL compiler在IBM 7094电脑中完成。
下列是马丁查理斯的 BCPL distribution.
Printing factorials:
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)
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
}
Why are we here?
All text is available under the terms of the GNU Free Documentation License
This page is cache of Wikipedia. History