删除的内容 添加的内容
InternetArchiveBot留言 | 贡献
Reformat 1 URL (Wayback Medic 2.5)) #IABot (v2.0.9.5) (GreenC bot
 
(未显示2个用户的23个中间版本)
第2行:
| name = BCPL
| logo =
| paradigm = [[编程|过程式]],[[令式编程|令式]],[[结构化编程|结构化]]
| year = {{start date and age|1967}}<ref name="IEEE_CPA_MRichards"/>
| designer = [[馬丁·理察德]]
第10行:
| latest_test_version =
| latest_test_date =
| typing = 无类型(所有东西都是[[字 (计算机)|字]])
| implementations =
| dialects =
第16行 ⟶ 第17行:
| operating_system =
| license =
| website = {{URL|https://www.cl.cam.ac.uk/~mr10/BCPL.html}}
| website =
}}
 
'''基本組合編程語言'''({{lang-en|Basic Combined Programming Language}}),是一種電腦程式設計語言,源自更早的[[CPL (程式語言)|CPL]]語言,1967年由劍橋大學的[[馬丁·理察德]]所發展出來的<ref name="IEEE_CPA_MRichards">{{cite web |url=https://www.computer.org/web/awards/pioneer-martin-richards |title=Martin Richards (2003 Computer Pioneer Award) |author=<!--Not stated--> |publisher=IEEE Computer Society |date=<!--Not stated--> |access-date=2017-11-24 |archive-url=https://archive.istoday/20171124083723/https://www.computer.org/web/awards/pioneer-martin-richards |archive-date=2017-11-24 |dead-url-status =no dead}}</ref>
 
==概述==
Richards試著移除了CPL中最複雜的組成,第一支BCPL compiler在[[IBM 7090|IBM 7094]]電腦中完成。身為早期程式語言的BCPL,如今已不再廣泛使用,但它的影響卻是深遠的,今日流行的[[C語言]]即是參考BCPL所設計<ref name="C_Prog_Lang_KR">{{cite book |url=https://archive.org/details/cprogramminglang00bria |title=The C Programming Language |date=1978 |publisher=Bell Telephone Laboratories |isbn=0-13-110163-3 |pages=2 |authors=Kernighan, Brian W. and Dennis M. Ritchie}}</ref>。BCPL被认定为第一个{{en-link|花括号编程语言|Brace programming language}}<ref>{{cite web|url=https://www.cl.cam.ac.uk/~mr10/bcplman.pdf|title=The BCPL Cintsys and Cintpos User Guide, 2.1.4 Section brackets|quote=Historically BCPL used the symbols <code>$(</code> and <code>$)</code> 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 <code>{</code> and <code>}</code> as appropriate.}}</ref>,作为BCPL后代语言,[[C语言]]使用[[花括号]]来表示块结构。
Richards試著移除了CPL中最複雜的組成,第一支BCPL compiler在[[IBM 7094]]電腦中完成。身為早期程式語言的BCPL,如今已不再廣泛使用,但它的影響卻是深遠的,今日流行的[[C語言]]即是參考BCPL所設計。BCPL是第一支使用[[括弧語言]],[[括弧]]特徵在C語言中隨處可見,例如
:BCPL
LET FUNC foo(a) = VALOF
{ b := a + 1
RESULTIS b }
:C語言改良自BCPL
for (int i = 0; i < 10; i++)
'''{'''
printf("%d", i);
doTask(i);
'''}'''
 
== 範例 ==
第39行 ⟶ 第30行:
 
打印[[阶乘]]:
<syntaxhighlight lang="basic">
<pre>
GET "libhdrLIBHDR"
 
LET startSTART() = VALOF $(
{ FOR iI = 1 TO 5 DO writef("fact(%n) = %i4*n", i, fact(i))
WRITEF("%N! = %I4*N", I, FACT(I))
RESULTIS 0
RESULTIS bRESULTIS }0
}
$)
 
AND factFACT(nN) = nN = 0 -> 1, nN *fact FACT(nN - 1)
</syntaxhighlight>
</pre>
 
[[八皇后问题|N個皇后問題]]:
<syntaxhighlight lang="basic">
<pre>
GET "libhdrLIBHDR"
GLOBAL { count:200; all:201 }
LET try(ld, row, rd) BE TEST row=all
 
GLOBAL $(
THEN count := count + 1
COUNT: 200
ALL: 201
$)
 
LET TRY(LD, ROW, RD) BE
ELSE { LET poss = all & ~(ld | row | rd)
TEST ROW = ALL THEN
UNTIL poss=0 DO
COUNT { LET p := possCOUNT &+ -poss1
ELSE $(
poss := poss - p
LET POSS = ALL & try~(ld+p << 1,LD row+p,| rd+pROW >>| 1RD)
UNTIL POSS = 0 DO }$(
LET P = POSS & }-POSS
POSS := POSS - P
TRY(LD + P << 1, ROW + P, RD + P >> 1)
$)
$)
 
LET startSTART() = VALOF $(
{ all ALL := 1
FOR I = 1 TO 12 DO $(
FOR i = 1 TO 12 DOCOUNT := 0
{ count := TRY(0, 0, 0)
WRITEF("%I2-QUEENS PROBLEM HAS %I5 SOLUTIONS*N", I, COUNT)
try(0, 0, 0)
all ALL := 2 *all ALL + 1
writef("Number of solutions to %i2-queens is %i5*n", i, count)
$)
all := 2*all + 1
RESULTIS 0
}
$)
 
</syntaxhighlight>
RESULTIS 0
}
</pre>
 
==引用==
{{reflist|2}}
 
== 參考文獻 ==
第91行 ⟶ 第84行:
* Martin Richards, C. Whitby-Strevens, ''BCPL, the language and its compiler'' (Cambridge University Press, 1980) ISBN 0-521-28681-6
 
[[Category:{{程序设计语言|BCPL]]}}
 
[[Category:过程式编程语言|BCPL]]
[[Category:1967年建立的程式語言]]