CPL語言

CPL
编程范型多范型: 过程式, 指令式, 结构化, 函数式
設計者Christopher Strachey
发行时间1963年​(1963
受影响于
ALGOL 60
影響語言
BCPL, POP-2

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

例子

下面是Christopher Strachey等人在1963年论文中举出了的例子,它对应ALGOL 60报告中欧拉变换的例子:

function Euler [function Fct, real Eps, integer Tim] = result of
    || Euler computes the sum of Fct[i] fo​r i from zero up to infinity by 
    || means of a suitably refined Euler transformation. The summation is
    || stopped as soon as Tim ti​mes i​n succession the absolute value of 
    || the terms of the transformed series are found to be less than Eps.
    || Hence, one should provide a fu​nction Fct with one integer argument,
    || an upper bound Eps, and an integer Tim. The output is the sum Sum.
    || Euler is particularly efficient i​n the ca​se of a slowly convergent
    || or divergent alternating series.
    §1 dec §1.1 real Mn, Ds, Sum
                integer i, t
                index n = 0
                m = Array [real, (0, 15)] §⃒1.1
       i, t, m[0] := 0, 0, Fct[0]
       Sum := m[0]/2
       §1.2 i := i + 1
            Mn := Fct[i]
            for k = step 0, 1, n do
                m[k], Mn := Mn, (Mn + m[k])/2
            test Mod[Mn] < Mod[m[n]]  n < 15
                then do Ds, n, m[n+l] := Mn/2, n + 1, Mn
                or do Ds := Mn
            Sum := Sum + Ds
            t := (Mod[Ds] < Eps)  t + 1, 0 §⃒1.2
       repeat while t < Tim
       result := Sum §⃒1.

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

实现

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

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

引用

  1. ^ Coulouris, G. F. The London CPL1 compiler. The Computer Journal. 1 January 1968, 11: 26–30. doi:10.1093/comjnl/11.1.26可免费查阅 (英语). 
  2. ^ 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]. 
  3. ^ Peter Norvig. Prescient but Not Perfect: A Look Back at a 1966 Scientific American Article on Systems Analysis. Blogs.scientificamerican.com. [2013-08-18]. 
  4. ^ Norvig, Peter. Complete Annotated Checkers Program. norvig.com. [11 June 2021]. 

参考书目