ISWIM
| 编程范型 | 指令式, 函数式 |
|---|---|
| 設計者 | Peter J. Landin |
| 发行时间 | 1966年 |
| 作用域 | 词法 |
| 受影响于 | |
| ALGOL 60, Lisp | |
| 影響語言 | |
| PAL, SASL, ML, NPL, Lucid, Haskell | |
ISWIM(“If you See What I Mean”的首字母缩写),是的一种抽象的计算机编程语言或编程语言家族,它由Peter J. Landin设计,并描述在他1966年于ACM通讯发表的文章《The Next 700 Programming Languages》之中[1]。
尽管没有实现,它被证明为在编程语言开发中非常有影响力的语言,特别是对于函数式编程语言,比如SASL、ML、NPL、Haskell和它们的后继者,还有数据流程编程语言如Lucid。
设计
[编辑]ISWIM是具有函数式核心的指令式编程语言,它构成自加了语法糖的叫做“应用表达式”(AE)的lambda演算,并增加了可变变量和赋值,还有强力控制机制即对应J算子的程序点算子pp[2]。ISWIM的操作语义,使用Landin的SECD抽象机来定义,并且使用了传值调用,因而是及早求值的[3]。
ISWIM基于了lambda演算,从而具有高阶函数和词法作用域变量,其应用表达式为了“同时”或“平行”定义而扩展了在λ和.之间的标识符列表,为递归定义而采用了Y不动点算子。ISWIM的目标之一,就是要看起来更像数学表示,所以在定义结构之时,放弃了ALGOL的语句括号begin……end,转而采用了越位规则和基于缩进的作用域。
ISWIM程序基于了一个单一表达式,它由where或let子句、条件表达式和函数定义所限定。ISWIM在表示法上的特色,是与CPL一起,最早使用了where子句,尤其是let子句适合表达ALGOL 60的块结构而为后继者语言所承袭:
| AE | ISWIM | |
|---|---|---|
{λf.f(b+2c)+f(2b-c)}
[λx.x(x+a)]
{λ(f,b,c).f(b+2c)+f(2b-c)}
[λx.x(x+a),
u/(u+1),
v/(v+1)]
{λg.g({λf.f}[λx.ax²+bx+c],
u/(u+1),
v/(v+1))}
[λ(f,p,q).f(p+2q,2p-q)]
{λf.f(6)}[Yλf.λn.(n=0)→1 else→nf(n-1)]
{λx.xy(x+y)}
[{λy.a²+a√y}
[a²+b²]]
{λ(a,b,f).
{λ(g,h).
{λk.X}
[λ(u,v).λx.K]}
[Yλ(g,h).
(λx.G,λ(y,z).H)]}
[A,B,λ(x,y).F]
|
f(b+2c)+f(2b-c)
where f(x) = x(x+a)
f(b+2c)+f(2b-c)
where f(x) = x(x+a)
and b = u/(u+1)
and c = v/(v+1)
g(f where f(x) = ax²+bx+c,
u/(u+1),
v/(v+1))
where g(f,p,q) = f(p+2q,2p-q)
f(6) where rec f(n) = (n=0)→1; nf(n-1)
xy(x+y)
where x = a²+a√y
where y = a²+b²
X
where k(u,v)(x) = K
where rec g(x) = G
and h(y,z) = H
where a = A
and b = B
and f(x,y) = F
|
let f(x) = x(x+a)
f(b+2c)+f(2b-c)
let f(x) = x(x+a)
and b = u/(u+1)
and c = v/(v+1)
f(b+2c)+f(2b-c)
let g(f,p,q) = f(p+2q,2p-q)
g((let f(x) = ax²+bx+c; f),
u/(u+1),
v/(v+1))
let rec f(n) = ((n=0)→1; nf(n-1)); f(6)
let x =
let y = a²+b²; a²+a√y
xy(x+y)
let a = A
and b = B
and f(x,y) = F
let rec g(x) = G
and h(y,z) = H
let k(u,v)(x) = K
X
|
在ISWIM论文中首次出现了用来定义结构的代数数据类型定义,这是通过自然语言的either……or……和……and……描述完成的,但明确的表示出了“积之和”[4]:
| ISWIM | Standard ML |
|---|---|
an () is either , and has a , which is an or a , in which case it has a , which is an , and a , which is an , or a , …… or , …… or a , …… or , …… . |
datatype aexp
= SIMPLE of body
| COMBINATION of rator * rand
| CONDITIONAL ……
| ONE_ARMED ……
| LISTING ……
| BEET ……
and body = BODY of identifier
and rator = RATOR of aexp
and rand = RAND of aexp
|
实现和派生
[编辑]没有进行过直接实现ISWIM的尝试,但Arthur Evans的PAL[5],和John C. Reynolds的Gedanken[6],获取了Landin的多数概念,包括强力的控制转移操作,这两者都是动态类型语言。Robin Milner的ML,可以被认为等价于没有J算子,而有类型推论的ISWIM。
从ISWIM衍生出的另一条路线,是去掉指令式特征即赋值和J算子,而只留下纯函数式语言[7],接着就有可能切换到惰性求值。这条路线导致了SASL、Hope、KRC、Miranda、Haskell、Clean。
引用
[编辑]- ^ Landin, P. J. The Next 700 Programming Languages (PDF). Communications of the ACM (Association for Computing Machinery). March 1966, 9 (3): 157–165 [2021-08-28]. S2CID 13409665. doi:10.1145/365230.365257. (原始内容 (PDF)存档于2022-03-23).
- ^ Landin, P.J. A Generalization of Jumps and Labels (PDF). 1965.
Thielecke, H. An Introduction to Landin's "A Generalization of Jumps and Labels". Higher-Order and Symbolic Computation. December 1998, 11 (2): 117–123. S2CID 1562780. doi:10.1023/A:1010060315625. - ^ Gordon Plotkin. Call-by-Name, Call-by Value and the Lambda Calculus (PDF) (报告). 1975 [2020-04-26]. (原始内容 (PDF)存档于2020-02-01).
- ^ Turner, D. A., Some History of Functional Programming Languages (PDF), Lecture Notes in Computer Science 7829, Berlin, Heidelberg: Springer Berlin Heidelberg: 1–20, 2013 [2024-01-28], ISBN 978-3-642-40446-7, doi:10.1007/978-3-642-40447-4_1,
The ISWIM paper also has the first appearance of algebraic type definitions used to define structures. This is done in words, but the sum-of-products idea is clearly there.
- ^ Arthur Evans. PAL: a language designed for teaching programming linguistics. Proceedings ACM National Conference. ACM National Conference. Association for Computing Machinery. 1968.
A. Evans. PAL -- A Reference Manual and a Primer (PDF) (报告). Department of Electrical Engineering, Massachusetts Institute of Technology. February 1968 [2021-09-09]. (原始内容 (PDF)存档于2022-03-06).
A. Evans. Appendix 2.1. The Complete Syntax for PAL (PDF) (报告). February 1968 [2021-09-10]. (原始内容 (PDF)存档于2022-03-06).
J. M. Wozencraft, A. Evans. Notes on Programming Linguistics (PDF). M.I.T. Department of Electrical Engineering. 1971 [2021-09-11]. (原始内容 (PDF)存档于2022-03-06). - ^ John C. Reynolds. GEDANKEN: a simple typeless language which permits functional data structures and co-routines (PDF) (报告). Argonne National Laboratory. September 1969 [2021-09-09]. (原始内容 (PDF)存档于2021-09-09).
John C. Reynolds. Definitional interpreters for higher-order programming languages. ACM '72: Proceedings of the ACM annual conference - Volume. August 1972 [2022-11-19]. doi:10.1145/800194.805852. (原始内容存档于2022-11-27). - ^ Ivanović, Mirjana; Budimac, Zoran. A definition of an ISWIM-like language via Scheme. ACM SIGPLAN Notices. April 1993, 28 (4): 29–38. S2CID 14379260. doi:10.1145/152739.152743.