跳转到内容

CPL語言

维基百科,自由的百科全书
(重定向自CPL (程式語言)
CPL
编程范型多范型: 过程式, 指令式, 结构化, 函数式
設計者Christopher Strachey
发行时间1963年,​63年前​(1963
受影响于
ALGOL 60
影響語言
BCPL, POP-2

CPL(英語:Combined Programming Language,原名Cambridge Programming Language),一種計算機程式語言。源自於ALGOL 60,在1963年,由英国剑桥大学伦敦大学首先開發出來。CPL语言在ALGOL 60的基础上更接近硬件一些,但规模比较大,难以实现。BCPL是它的後繼語言。

例子

[编辑]

函数MAX由Peter Norvig公式化为如下[1]

Max(Items, ValueFunction) = value of
§ (Best, BestVal) = (NIL, -∞)
  while Items do §
    (Item, Val) = (Head(Items), ValueFunction(Head(Items)))
    if Val > BestVal then (Best, BestVal) := (Item, Val)
    Items := Rest(Items) §⃒
  result is Best §⃒

与开符号§相匹配的闭符号是有竖杠贯穿的§。这个符号在Unicode中可以复合为§⃒,它是§(U+00A7)复合于(U+20D2),但在浏览器中不一定能正确的显示出来这个§⃒。

实现

[编辑]

据认为CPL在1960年代从未被完全实现,它是作为具有一些关于部份实现的研究工作的理论性构造而存在的[2][3]

Peter Norvig曾经用Yapps(一个Python编译器生成器)为现代机器写出了一个简单的CPL到Python转译器[1][4]

引用

[编辑]
  1. ^ 1.0 1.1 Peter Norvig. Prescient but Not Perfect: A Look Back at a 1966 Scientific American Article on Systems Analysis. Blogs.scientificamerican.com. [2013-08-18]. 
  2. ^ Coulouris, G. F. The London CPL1 compiler. The Computer Journal. 1 January 1968, 11: 26–30. doi:10.1093/comjnl/11.1.26可免费查阅 (英语). 
  3. ^ Coulouris, George. Computer Resurrection Issue 62 / The Compiler Compiler - Reflections of a User 50 Years On / The CPL1 Compiler. Computer Conservation Society. 2013 [2023-05-03]. 
  4. ^ Norvig, Peter. Complete Annotated Checkers Program. norvig.com. [11 June 2021]. 

参考书目

[编辑]