# Simula

编程范型 多范型: 指令式, 过程式, 结构化, 物件導向, 并发 奧利-約翰·達爾 克利斯登·奈加特 1962年，​60年前（Simula I）1967年，​55年前（Simula 67） Standard SIMULA[1] （ 1986年8月25日，​36年前 ） 静态、 主要为ALGOL 60（有一些Simscript构件） 类Unix系统、Windows、z/OS、TOPS-10、MVS（英语：MVS） Portable Simula Revisited[2], GNU Cim[3] ALGOL 60, Simscript[4] Smalltalk、CLU[5]、C++、BETA、Object Pascal、Modula-3、Java

Simula，一種編譯式程式語言，由奧利-約翰·達爾克利斯登·奈加特，在1960年代於奧斯陸，開發出來了Simula I與Simula 67兩代。它承繼了ALGOL 60作為基礎，被認為是第一個物件導向程式設計的程式語言。

Simula 67介入了对象子类（后来惯称为子类继承超类）、虚过程[6]，还有协程离散事件模拟和特征性的垃圾收集[7]。Simula的影響经常被低估[8]，在C++Object PascalModula-3Java和后来的很多编程语言中，都实现了受Simula启发的对象。BETA是Simula的现代后继者。

## 歷史

1963年8月，（NCC）購買到，在UNIVAC的合約同意下，奧利-約翰·達爾在這台電腦上安裝以ALGOL 60的編譯器來實作的Simula I。1965年1月，Simula I終於可以在UNIVAC 1107上完全的運作。接下來幾年，克利斯登·奈加特奧利-約翰·達爾致力於教授Simula I。Simula I也被移植到 B5500電腦，以及蘇聯的電腦上。

1965年，東尼·霍爾首次提出“記錄類別”（record class）構造的概念[10]，1966年，克利斯登·奈加特奧利-約翰·達爾通过將Simula I的進程當作由前綴層和主要層二者構成，把它擴展成了具有了記錄類別屬性的通用進程，他們當時所稱“進程”隨即被稱為“物件[11]。1967年5月，奈加特和達爾在奧斯陸舉辦的IFIP工作小組論壇中，發表了關於類別子類別聲明的論文，形成Simula 67的第一份定義文件[12]

1968年召開的會議，組成了SIMULA標準小組，並發表了第一份官方Simula標準文件「SIMULA 67通用基础语言」[13]。在1960年代后期和1970年代早期，Simula 67主要实现于四个系统之上：UNIVAC ，挪威计算中心的IBM System/360奥斯陆大学Kjeller英语Kjeller联合安装的CDC ，和（FOA）的DEC TOPS-10

Simula影响了Smalltalk[15]，和后来的面向对象编程语言[8]。Simula经由Smalltalk启发了并发计算的演员模型[16]C++語言和Java語言的創始人，都認可自己受到了Simula的重要影響[17]

## 特征概念

Simula 67包含通用算法语言ALGOL 60的多数特征作为自己的子集[1]。它是大小写不敏感的。

### 块与过程

ALGOL 60中最强力的编程构造机制之一，就是过程的概念。

#### 语法

L: L: ... begin D; D; ... D; S; S; ... S; S end


• 在这个块内出现的标识符，可以通过合适的声明，而被指定为局部于所论及的这个块。在这个块内侧的这个标识符所表示的实体，不存在于它的外侧。在这个块外侧的这个标识符所表示的任何实体，在这个块内侧是不可见的；在Simula 67中，可通过连接或远程访问使它成为可见的。
• 除了表示标签的标识符之外，一个标识符，如果出现在一个块中，而且并非声明于这个块中，则它非局部于这个块，就是说它所表示的这个块内侧实体，与在紧接它外侧的层级中出现的同名实体是同一个实体。因为块中的语句自身可以是一个块，局部和非局部于一个块的概念，必须递归地去理解，就是说非局部于一个块A的一个标识符，可是亦可否地，非局部于A是其中语句的块B

#### 语义

• 当一个块执行的时候，生成这个块的一个动态实例[23]。在计算机中，一个块实例可以采用一种形式的内存区域，它包含需要的动态块信息，并包括空间来持有局部于这个块的变量的内容[24]
• 块实例中的局部变量，标识了分配给块实例的内存片段。于内部块的标识符绑定，对这个内部块的任何随后的动态实例，保持有效[25]

• 定义函数指示符的值的过程，以类型声明符作为其过程声明的最先[29]。此外的真正（proper）过程，在Simula 67中，被称为具有普遍（universal）类型，任何类型都从属（subordinate）于普遍类型。在Simula 67中，过程的参数列表( … <参数分界符> … )，舍弃了其中对ALGOL 60是可选的“) <字母串>: (”样式的参数分界符英语Delimiter[30]
• 过程的缺省的传送模态，在Simula 67中，对于值类型的参数是传值调用，对于所有其他类型的参数是传引用调用；故而在过程声明的参数规定中，增加了以name为前导的名字部份，用来指定所述及的参数采用传名调用。在过程主体内传名调用的形式参数的每次出现，都引起对实际参数的一次求值。在Simula 67中，这个求值发生在过程语句的上下文中，就是说不会出现标识符冲突，因为过程主体和它的变量此时是不可见的。
• 过程调用的执行，在有参数的情况下要经历如下步骤：建立形式参数块实例；求值对应于传值调用或传引用调用的实际参数，并将其结果赋值给形式参数块实例的对应变量[31]；过程主体被初始化并开始执行。

### 对象与类

Simula 67的中心概念是对象，一个对象是一段（self-contained）程序（块实例），它拥有由一个声明定义的自己的局部数据和行动（action）。操纵对象和相互关联对象的需要，致使语言必须介入列表处理设施。

• 对于一个给定对象，形式参数，在由virtual:前导的虚拟部份中规定的，和声明为局部于类主体（body）的量，叫做这个对象的特性（attribute）。一个特性的声明或规定叫做特性定义。在1986年修订的语言标准中，通过由hidden亦或protected前导的保护规定，可以限制类特性标识符的可见性。
• 类声明的形式参数，不适用传名调用[33]。在规定部份中需要对每个形式参数进行规定，这些参数被当作局部于类主体的变量，可以接受如下规定符（specifier）：<类型>array<类型> array
• 类主体通常是一个，即使它如语法形式所允许的那样是块以外的一个语句，也表现得如同一个块。一个分裂（split）主体，担当其中符号inner表示一个虚设（dummy）语句的块。

class Order (number); integer number;
begin integer numberOfUnits, arrivalDate;
real processingTime;
end;


new Order (103);


Simula 67为了将整个程序执行组织为属于对象的活动阶段的一个序列，而包含了其所必需的基本特征。在模拟器Simulation的声明中，定义了叫做“定序集合”（sequencing set）的一个“时间轴”，它也是充当队列的一个双向列表，还有进程Process，它给与对象将其活动阶段通过时间轴来组织的一种属性

### 子类

Cn是具有前缀序列C1, C2, ...... Cn-1的一个类，这里Ckk = 1,2,...,n）的下标k叫做前缀层级，则属于Cn的对象是一个复合对象，它可以用串接的类声明来正式的描述，串接的过程被认为先于程序执行而发生。 设X是属于Cn的的一个对象。非正式的说，串接机制有如下结果：

• X拥有的特性集合，是在C1, C2, ... , Cn中所定义集合的并集。在Ck1 <= k <= n）中定义的特性，被称为定义在前缀层级k
• X拥有的“运算规则”，构成自来自在这些类的主体的语句，并且它们依据了预先规定的次序。来自Ck的语句，被称为属于X的前缀层级k
• X的前缀层级k的语句，能访问在X的等于或外部于k的前缀层级上定义的它的所有特性，但是不能直接访问由于在外部于k层级的冲突定义而导致不可见的特性。这些不可见特性仍然可以访问，例如通过使用过程或this
• X的前缀层级k的语句，不能立即访问在X的内部于k的前缀层级上定义的它的那些特性，除非通过虚拟量。
• 在前缀层级k的分裂主体中，符号inner，表示X的属于内部于k的前缀层级的运算规则的那些语句，或者在k = n时表示虚设语句。如果C1, ... , Cn-1都没有分裂主体，则在X的运算规则中的那些语句，依据升序前缀层级来排序。

Order class BatchOrder;
begin integer batchSize;
real setupTime;
end;

Order class SingleOrder;
begin real setupTime, finishingTime, weight; end;

SingleOrder class Plate;
begin real length, width; end;


### 引用

ref(Order) next, previous;


next :- new Oreder(101);
previous :- next;
next :- new Plate(50);


### 对象表达式

1. 生成这个对象，并且这个对象生成式如果有实际参数，则求值它们，将得到的这些值及或英语And/or引用传送给形式参数。
2. 控制经过这个对象最初的begin进入其中，借此它变成在“系附”状态下运行。在生成的对象执行了detach基本过程，或者经过这个对象最终的end退出的两种情况之一时，对象生成式的求值完成。

this C，如果用在类CC的任何子类的类主体中，或用在其块限定为类CC的一个子类的连接块中，则这个对象表达式是有效的。在一个给定的上下文中，一个局部对象的值，是一个对象或连接到一个对象，它是这个对象表达式在其中有效的、最小的字面上包围的块实例；如果没有这样的块，则这个对象表达式在这个上下文中是非法的。对于一个过程或类主体的实例（上下文），“字面上包围”意为包含它的声明。如此定义的内涵参见示例章节中的二叉树实例。

X表示一个简单的引用表达式，而CD是类标识符，使得类D是对象X的限定。对于限定对象X qua C，如果类C外部于或等于类D，或者是D的一个子类，则这个对象表达式是合法的，否则是为非法。如果X的值是none，或者是属于外部于C的类的一个对象，则这个对象表达式求值形成一个运行时间错误；在其他情况下，X qua C的值，就是X的值。这种对一个串接的类对象的即时限定，约束或扩展它的特性通过检视或远程访问的可见性。

### 远程访问

1. 这个对象
2. 外部于或等于这个对象的类的一个
3. 在这个类中或在属于它的前缀序列的任何类中定义的一个特性标识符

if next.number >= previous.number then ......;


“组访问”可通过“连接语句”来完成，连接机制的用途，是为在连接块中的特定识别，提供上述第1项对象信息和第2项类信息的隐式定义。例如：

inspect next when Plate do begin ...... end;
inspect new Plate(50) do begin ...... end;


### 虚过程

• 允许在一个对象的一个前缀层级上，访问在内部前缀层级上声明的特性。
• 允许在一个前缀层级上的特性重新定义，在外部前缀层级上有效。

class Hashing (n); integer n;
virtual: integer procedure hash;
begin
integer procedure hash(t); text t;
begin ...... end hash;
text array table (0:n-1); integer entries;
integer procedure lookup (t,old);
name old; Boolean old; text t;
begin ...... end lookup;
end Hashing;

Hashing class ALGOL_hash;
begin
integer procedure hash(T); text T;
begin ...... end hash;
end ALGOL_hash;

Hashing(64) begin
integer procedure hash(T); text T;
begin ...... end hash;
......
end


### 作用域和可见性

• 一个标识符定义的作用域，是它在其中可能有作用的那一部份程序正文。相同的标识符，可以定义在程序的很多地方，因此可以关联于不同的量。这种相同的标识符的作用域，因而可能重叠，例如当一个标识符在内部块中被重新声明的情况下。
• 一个标识符定义，这个标识符在程序的一个给定点上，如果能够涉及到所论及声明的量，则这个定义被称为在这个点上是的。在给定标识符于此可见的程序正文的一个特定点上，最多只能有一个定义关联于这个标识符，例如在上述重新声明的情况下，在它们作用域的并集内任何给定点上，只有一个定义是可见的。

• 具有相同标识符的一个标识符定义，即这个标识符的重新定义，出现在以前的定义的局部块所包围的某个构造内。在它们共同的作用域内，只有最内部的重新定义是可见的。
• 一个重新定义，出现在类的某个内部前缀层级。
• 远程访问，可以导致某些标识符定义在检视块或点表示法内变成不可见的。
• 使用thisqua，可以导致一个或多个重新定义被临时停止。
• 这个定义所局部于的类声明的保护部份。

### 块实例

• 一个非类块实例，也就是有前缀块、子块、过程主体或连接块的实例，总是在系附状态下，这个实例被称为系附到了导致它生成的那个块上。因此一个过程体的实例，系附到包含对应函数指示符或过程语句的块实例上。非类、非过程块实例，系附到它所局部的块实例。在PSC到达非类块实例的最终的end的时候，PSC返回到紧随导致这个块实例生成的语句或表达式的程序点。
• 一个对象，最初是在系附状态下，并被称为系附到包含对应对象生成语句的那个块实例上。一个对象，可以通过执行detach语句，进入脱离状态。通过执行call语句，可以使一个脱离状态的对象重新进入系附状态，它借此变为系附到包含这个调用语句的那个块实例上。通过执行resume语句，可以使一个脱离状态的对象进入恢复状态。不使用detachcallresume语句的一个程序执行，是一个简单的系附状态的块的嵌套结构。
• 当PSC通过一个对象的最终end，或通过goto语句离开它的时候，这个对象进入终止状态。没有块实例系附到一个终止状态的类对象上。终止状态的对象，仍作为一个数据项而存在，它可以通过针对这个对象的包括过程和函数特性的这些特性的远程标识来引用。

### 准并行系统

• 在任何时间，在一个系统的组件之中，有确切的一个组件被称为“生效”（operative）的。不生效的组件，有关联的“重新激活点”，它标识在这个组件被激活（activate）时，要在它那里继续执行的程序点。一个对象组件是生效的，当且仅当这个组件的头领处在恢复状态。
• 除了系统组件，程序执行还可以包含不属于特定系统的“独立对象组件”。任何这种组件的头领，都是一个脱离状态的对象，它局部于一个类对象或过程主体的一个实例，也就是说不局部于系统头领（子块或有前缀块的实例）。根据定义，独立组件总是不生效的。

• 将当前包含PSC的块实例动态包围起来的块实例链，叫做“运行”。在运行链上的块实例，被称为“运行”（operating）的，最外层的块实例总是运行的。一个系统如果有一个组件是运行的，它就是运行的；在任何时间，一个系统最多有一个组件是运行的；运行的系统的头领，可以是不运行的（不在运行链上）。一个运行的组件 ，总是生效的；如果一个系统的生效组件是不运行的，则这个系统也是不运行的。在不运行的系统中的生效的组件，是当这个系统成为不运行的时候在运行的组件，当这个系统再次成为运行的时候它将仍是运行的。
• 对于一个不生效的组件C，如果一个块实例P包含了它的重新激活点（而C的重新激活点关联于C的头领），则PC的头领动态包围，并且P除了自身之外不动态包围块实例。由PC的头领X“动态”的块实例序列(P = Z0) → Z1 → .... → Zn-1 → (Zn = X) (n>=0)，被称谓为C的“重新激活链”。除了C的头领X（脱离状态的对象）之外，这个链上的所有组件头领（恢复状态的对象），标识了生效而不运行的组件。在C成为运行的时候，在它的重新激活链上所有块也成为运行的。

### 定序

• 对于一个不生效的对象组件，通过针对它的脱离状态的头领，执行一个call，可以重新激活这个组件，借此PSC移动到它的重新激活点上。这个头领重新进入系附状态，并变成系附到包含这个call的块实例上。这个组件正式的失去了本身（作为组件）的状态。

• 对于这个系统的一个不生效的对象组件，通过针对它的脱离状态的头领，执行一个resume，可以重新激活这个组件，借此PSC移动到它的重新激活点上；这个组件的头领进入恢复状态，而这个组件变成生效的。这个系统以前生效的组件变成不生效的，并且它重新激活点被定位到紧后于这个resume；如果这个组件是一个对象组件，则它的头领进入脱离状态。
• 对于当前生效的对象组件，通过针它的恢复状态的头领，执行一个detach，这个系统的主干组件重获生效的状态，借此PSC移动回到主干组件的重新激活点上。以前生效的组件变成不生效的，并且它重新激活点被定位到紧后于这个detach。这个组件的头领进入脱离状态。

PSC经过一个类对象的最终end的效果，除了使这个对象成为终止状态，而非脱离状态之外，相同于针对这个对象执行detach的效果。其结果是它不会得到重新激活点，并且在它已经拥有作为组件头领的状态时，失去这种状态。

## 程式範例

### 最小程序

Begin
End;


### Hello, World!

Simula 67的经典Hello, World!範例：

Begin
OutText ("Hello, World!");
OutImage;
End;


OutText过程将字符串输出到缓冲区，而OutImage过程将缓冲区内容输出到标准文件，二者都定义在输出文件类OutFile中，而它是文件类File的子类。

### 传名调用

Real Procedure Sigma (k, m, n, u);
Name k, u;
Integer k, m, n; Real u;
Begin
Real s;
k:= m;
While k <= n Do Begin s:= s + u; k:= k + 1; End;
Sigma:= s;
End;


Z:= Sigma (i, 1, 100, 1 / (i + a) ** 2);


### 协程

Simula 67标准通过如下实例来诠释叫做“准并行系统”的协程机制：

begin comment S1;
ref(C1) X1;
class C1;
begin procedure P1; detach;
P1
end C1;
ref(C2) X2;
class C2;
begin procedure P2;
begin detach;
! 可尝试detach或resume(X1);
end P2;
begin comment system S2;
ref(C3) X3;
class C3;
begin detach;
P2
end C3;
X3:- new C3;
resume(X3)
end S2
end C2;
X1:- new C1;
X2:- new C2;
call(X2); ! 可尝试resume(X2);
end S1;


[S1] ← (X1) ← (P1) ← PSC


[S1] ← PSC
|
(X1) ← (P1) ← X1重新激活点


[S1] ← (X2) ← [S2] ← (X3) ← PSC
|
(X1) ← (P1) ← X1重新激活点


[S1] ← (X2) ← [S2] ← PSC
|             |
|            (X3) ← X3重新激活点
|
(X1) ← (P1) ← X1重新激活点


PSC到达系统S2主干组件的第20行，执行resume(X3)语句后，保存系统S2主干组件的重新激活点为第21行，PSC恢复到第17行的对象X3的类主体之中，这时的情况是：

[S1] ← (X2) ← [S2] ← S2重新激活点
|             |
|            (X3) ← PSC
|
(X1) ← (P1) ← X1重新激活点


                                   ! 状况A
[S1] ← (X2) ← [S2] ← S2重新激活点
|             |
|            (X3) ← (P2) ← PSC
|
(X1) ← (P1) ← X1重新激活点


                                   ！状况B
[S1] ← PSC
|
(X1) ← (P1) ← X1重新激活点
|
(X2) ← [S2] ← S2重新激活点
|
(X3) ← (P2) ← X2重新激活点


[S1] ← S1重新激活点
|
(X1) ← (P1) ← X1重新激活点
|
(X2) ← [S2] ← S2重新激活点
|
(X3) ← (P2) ← PSC


[S1] ← S1重新激活点
|
(X1) ← (P1) ← PSC
|
(X2) ← [S2] ← S2重新激活点
|
(X3) ← (P2) ← X2重新激活点


### 二叉树

class Tree (val); integer val;
begin
ref (Tree) left, right;
procedure insert (x); integer x;
begin
if x < val then
begin
if left == none then
left :- new Tree (x)
else left.insert (x)
end
else if right == none then
right :- new Tree (x)
else right.insert (x);
end
ref (Tree) procedure find (x); integer x;
begin
if x = val then
this Tree
else if x < val then
(if left == none then none
else left.find (x))
else if right == none then none
else right.find (x);
end
end of tree;


find的过程体中出现了表达式this Tree，它意图产生的值是到当前节点的引用，就是说这个节点拥有find特性的“这个”特定实例。例如，如果通过函数指示符X.find (x)，来调用Xfind过程，并且X.val = x，则这个函数的结果是X自身的引用值。

### 抽象类

Begin
Class Glyph;
Virtual: Procedure print Is Procedure print;
Begin
End;

Glyph Class Char (c);
Character c;
Begin
Procedure print;
OutChar(c);
End;

Glyph Class Line (elements);
Ref (Glyph) Array elements;
Begin
Procedure print;
Begin
Integer i;
For i:= 1 Step 1 Until UpperBound (elements, 1) Do
elements (i).print;
OutImage;
End;
End;

! 主程序;
Ref (Glyph) rg;
Ref (Glyph) Array rgs (1 : 4);

rgs (1):- New Char ('A');
rgs (2):- New Char ('b');
rgs (3):- New Char ('b');
rgs (4):- New Char ('a');
rg:- New Line (rgs);
rg.print;
End;


### 模拟器

Simulation Begin
Class FittingRoom;
Begin
Boolean inUse;
Procedure request;
Begin
If inUse Then Begin
Wait (door);
door.First.Out;
End;
inUse:= True;
End;
Procedure leave;
Begin
inUse:= False;
Activate door.First;
End;
End;

Procedure report (message); Text message;
Begin
OutFix (Time, 2, 0); OutText (": " & message); OutImage;
End;

Process Class Person (pname); Text pname;
Begin
While True Do
Begin
Hold (Normal (12, 4, u));
report (pname & " 要求用试衣间");
fittingroom1.request;
report (pname & " 已进入试衣间");
Hold (Normal (3, 1, u));
fittingroom1.leave;
report (pname & " 已离开试衣间");
End;
End;

Integer u;
Ref (FittingRoom) fittingRoom1;

fittingRoom1:- New FittingRoom;
Activate New Person ("Sam");
Activate New Person ("Sally");
Activate New Person ("Andy");
Hold (100);
End;


## 注释

1. SIMULA Standards Group. SIMULA Standard (PDF). 1986 [2022-03-23]. （原始内容 (PDF)存档于2022-04-07）. In this Standard the name SIMULA is considered synonymous with SIMULA 67. …… It is recommended that the language defined in this Standard be referred to as "Standard SIMULA".
SIMULA includes most of the ALGOL 60 language. Wherever ALGOL is used in this Standard it relates to the STANDARD ALGOL 60 definition (ISO 1538).
2. Portable Simula Revisited. [2022-03-15]. （原始内容存档于2022-05-11）.
3. GNU Cim. [2022-04-02]. （原始内容存档于2022-04-14）.
4. ^ Kristen Nygaard; Ole-Johan Dahl. The Development of the Simula Languages (PDF). 1978 [2022-03-14]. （原始内容 (PDF)存档于2022-01-20）. SIMSCRIPT was the only simulation language that we were closely acquainted with during the design phase of SIMULA. From the preceding sections it will be evident that it had a considerable impact through its list processing and time scheduling mechanisms. It also contained a set of random drawing and other utility routines, which served as a model for our procedure library.
5. ^ Barbara Liskov. A history of CLU (PDF). 1992 [2022-04-27]. （原始内容 (PDF)存档于2021-11-05）. Programming languages that existed when the concept of data abstraction arose did not support abstract data types, but some languages contained constructs that were precursors of this notion. …… The mechanism that matched the best was the class mechanism of Simula 67. A Simula class groups a set of procedures with some variables. A class can be instantiated to provide an object containing its own copies of the variables; the class contains code that initializes these variables at instantiation time. However, Simula classes did not enforce encapsulation ……, and Simula was lacking several other features needed to support data abstraction, …….
6. Ole-Johan Dahl. The Birth of Object Orientation: the Simula Languages (PDF). 2001 [2022-04-13]. （原始内容 (PDF)存档于2021-08-10）. On the other hand, if a procedure P is specified as virtual in a class C the binding scheme is semi-dynamic. Any call for P occurring in C or in any subclass of C will bind to that declaration of P which occurs at the innermost prefix level of the actual object containing such a declaration (and similarly for remote accesses). Thus, the body of the procedure P may, at the prefix level of C, be postponed to occur in any subclass of C. It may even be replaced by more appropriate ones in further subclasses.
This binding scheme is dynamic in the sense that it depends on the class membership of the actual object. But there is nevertheless a degree of compiler control; the access can be implemented as indirect through a produced by the compiler for C and for each of its subclasses. ……
a virtual procedure can be seen as a parameter, where the actual parameter is a procedure residing safely within the object itself, at an appropriate prefix level. There is the additional advantage that the procedure has direct access to attributes of the object containing it.
7. O. -J. Dahl; C. A. R. Hoare. Hierarchical Program Structures. C. A. R. Hoare (编). Structured Programming. London, UK: Academic Press. 1972: 175–220. ISBN 978-0122005503. In SIMULA 67, a block instance is permitted to outlive its calling statement, and to remain in existence for as long as the program needs to refer to it. It may even outlive the block instance that called it into existence. As a consequence, it is no longer possible to administer storage allocation as a simple stack; a general garbage-collector, including a scan-mark operation, is required to detect and reclaim those areas of store (local workspace of block instances) which can no longer be referenced by the running program. The reason for accepting this extra complexity is that it permits a wider range of concepts to be conveniently expressed. In particular, it clarifies the relationship between data and the operations which may be performed upon it, in a way which is awkward or impossible in ALGOL 60.
8. Ole-Johan Dahl. The Birth of Object Orientation: the Simula Languages (PDF). 2001 [2022-04-13]. （原始内容 (PDF)存档于2021-08-10）. The main impact of Simula 67 has turned out to be the very wide acceptance of many of its basic concepts: objects, but usually without own actions, classes, inheritance, and virtuals, often the default or only way of binding “methods”, (as well as pointers and dynamic object generation).
There is universal use of the term “object orientation”, OO. Although no standard definition exists, some or all of the above ideas enter into the OO paradigm of system development. There is a large flora of OO languages around for programming and system specification. …… The importance of the OO paradigm today is such that one must assume something similar would have come about also without the Simula effort. The fact remains, however, that the OO principle was introduced in the mid 60’s through these languages.
Simula 67 had an immediate success as a simulation language, and was, for instance extensively used in the design of VLSI chips, e.g. at INTEL. As a general programming language, its impact was enhanced by lectures at given by OJD, materialized as a chapter in a book on structured programming. The latter has influenced research on the use of abstract data types, e.g., the CLU language, as well as research on and operating system design.
A major new impact area opened with the introduction of workstations and personal computers. Alan Kay and his team at Xerox PARC developed Smalltalk, an interactive language building upon Simula’s objects, classes and inheritance. It is oriented towards organising the cooperation between a user and her/his personal computer.
9. ^ Kristen Nygaard. SIMULA: An Extension of ALGOL to the Description of Discrete-Event Networks. Proceedings of the IFIP congress 62, Munich. North-Holland Publ., pages 520-522. Aug 1962.
10. ^ C. A. R. Hoare. Record Handling (PDF). ALGOL Bulletin no. 21. 1965 [2022-03-14]. （原始内容 (PDF)存档于2022-04-07）.
11. ^ Jan Rune Holmevik. Compiling Simula. Oslo, Norway: Institute for Studies in Research and Higher Education. 1994. （原始内容存档于2020-01-11）. During the summer and autumn of 1963, …… Instead Dahl and Nygaard introduced the far more powerful process concept which came to constitute the basic, unifying feature of the SIMULA I language. In short, a process can be understood as a generalized ALGOL procedure with quasi-parallel properties. ……
they became more and more preoccupied with the opportunities embedded in Tony Hoare's record class construct, first presented in ALGOL bulletin no. 21, 1965. …… What they were really looking for was some kind of generalized process concept with record class properties. The answer to their problem suddenly appeared in December 1966, when the idea of prefixing was introduced. A process, later called an object, could now be regarded as consisting of two layers: A prefix layer containing references to its predecessor and successor along with a number of other properties, and a main layer containing the attributes of the object in question. In addition to this important new feature, they also introduced the class concept, which can roughly be described as a highly refined version of SIMULA I's activity concept. This powerful new concept made it possible to establish class and subclass hierarchies of concatenated objects.
12. ^ Ole-Johan Dahl; Kristen Nygaard. Class and Subclass Declarations (PDF). North Holland: J. Buxton,ed.: Simulation Programming Languages. Proceedings from the IFIP Working Conference in Oslo, May 1967. 1968 [2020-05-16]. （原始内容 (PDF)存档于2022-04-08）.
13. ^ Ole-Johan Dahl; Bjørn Myhrhaug; Kristen Nygaard. SIMULA 67 Common Base Language (PDF). Norwegian Computing Center. 1968, 1970 [2022-02-13]. （原始内容 (PDF)存档于2022-04-07）.
14. ^ Swedish standard SS 63 61 14 (PDF). [2022-04-14]. （原始内容 (PDF)存档于2022-04-16）.
15. ^ Alan Kay. The Early History of Smalltalk. [2022-04-11]. （原始内容存档于2011-04-29）. I wound up in graduate school at the University of Utah in the Fall of 1966, ……. …… The documentation was incomprehensible. Supposedly, this was the Case-Western Reserve Algol – but it had been doctored to make a language called Simula; the documentation read like Norwegian transliterated into English, which in fact it was. There were uses of words like activity and process that didn’t seem to coincide with normal English usage. ……
The weirdest part was the storage allocator, which did not obey a stack discipline as was usual for Algol. …… What Simula was allocating were structures very much like the instances of Sketchpad. There wee descriptions that acted like masters and they could create instances, each of which was an independent entity. What Sketchpad called masters and instances, Simula called activities and processes. Moreover, Simula was a procedural language for controlling Sketchpad-like objects, thus having considerably more flexibility than constraints (though at some cost in elegance) ……. ……
For the first time I thought of the whole as the entire computer and wondered why anyone would want to divide it up into weaker things called data structures and procedures. Why not divide it up into little computers, as time sharing was starting to? But not in dozens. Why not thousands of them, each simulating a useful structure? ……
It is not too much of an exaggeration to say that most of my ideas from then on took their roots from Simula – but not as an attempt to improve it. It was the promise of an entirely new way to structure computations that took my fancy. As it turned out, it would take quite a few years to understand how to use the insights and to devise efficient mechanisms to execute them.
16. ^ ; Peter Bishop, Richard Steiger. A Universal Modular Actor Formalism for Artificial Intelligence (PDF). IJCAI. 1973 [2022-04-11]. （原始内容 (PDF)存档于2021-02-25）. Alan Kay whose FLEX and SMALLTALK machines have influenced our work. Alan emphasized the crucial importance of using intentional definitions of data structures and of passing messages to them. This paper explores the consequences of generalizing the message mechanism of SMALLTALK and SIMULA-67; …….
17. ^ Bjarne Stroustrup. A history of C++: 1979-1991 (PDF). History of programming languages---II (ACM). 1996: 699–769 [2022-03-22]. doi:10.1145/234286.1057836. （原始内容 (PDF)存档于2022-04-23）. C++ was designed to provide Simula’s facilities for program organization together with C’s efficiency and flexibility for systems programming.
James Gosling. The Feel of Java (PDF). 1997 [2022-04-27]. （原始内容 (PDF)存档于2022-02-28）. Java is a blue collar language. It’s not PhD thesis material but a language for a job. Java feels very familiar to many different programmers because I had a very strong tendency to prefer things that had been used a lot over things that just sounded like a good idea. …… It has an object-oriented flavor that derives from a number of languages—Simula, C/C++, Objective C, Cedar/Mesa, Modula, and Smalltalk.
18. ^ O. -J. Dahl; C. A. R. Hoare. Hierarchical Program Structures. C. A. R. Hoare (编). Structured Programming. London, UK: Academic Press. 1972: 175–220. ISBN 978-0122005503. useful properties from the standpoint of concept modelling. ……
⑷ Language element. A block is itself a statement, which is a syntactic category of the language. Furthermore, through the procedure mechanism, reference to a block may be dissociated from its defining text.
19. Peter Naur; et al. Revised Report on the Algorithmic Language Algol 60. [2022-04-14]. （原始内容存档于2007-06-25）. A switch declaration defines the set of values of the corresponding switch designators. These values are given one by one as the values of the designational expressions entered in the switch list. With each of these designational expressions there is associated a positive integer, 1, 2, ..., obtained by counting the items in the list from left to right. The value of the switch designator corresponding to a given value of the subscript expression ( …… ) is the value of the designational expression in the switch list having this given value as its associated integer.
20. ^ Peter Naur; et al. Revised Report on the Algorithmic Language Algol 60. [2022-04-14]. （原始内容存档于2007-06-25）. Every block automatically introduces a new level of nomenclature. This is realized as follows: Any identifier occurring within the block my through a suitable declaration ( …… ) be specified to be local to the block in question. This means ⒜ that the entity represented by this identifier inside the blocks has no existence outside it and ⒝ that any entity represented by this identifier outside the block is completely inaccessible inside the block.
Identifiers (except those representing labels) occurring within a block and not being declared to this block will be non-local to it, i.e. will represent the same entity inside the block and in the level immediately outside it. A label separated by a colon from a statement, i.e. labelling that statement, behaves as though declared in the head of the smallest embracing block, i.e. the smallest block whose brackets begin and end enclose that statement. In this context a procedure body must be considered as if it were enclosed by begin and end and treated as a block.
Since a statement of a block may again itself be a block the concepts local and non-local to a block must be understood recursively. Thus an identifier, which is non-local to a block A, may or may not be non-local to the block B in which A is one statement.
21. ^ O. -J. Dahl; C. A. R. Hoare. Hierarchical Program Structures. C. A. R. Hoare (编). Structured Programming. London, UK: Academic Press. 1972: 175–220. ISBN 978-0122005503. One of the most powerful mechanisms for program structuring in ALGOL 60 is the block and procedure concept. It has the following useful properties from the standpoint of concept modelling.
Duality. A block head and block tail together define an entity which has properties and performs actions. Furthermore the properties may include a data structure as well as associated operators (local procedures).
22. ^ O. -J. Dahl; C. A. R. Hoare. Hierarchical Program Structures. C. A. R. Hoare (编). Structured Programming. London, UK: Academic Press. 1972: 175–220. ISBN 978-0122005503. useful properties from the standpoint of concept modelling. ……
Decomposition. A block where only local quantities are referenced is a completely selfcontained program component, which will function as specified in any context. Through a procedure heading a block (procedure) instance may interact英语Interaction with a calling sequence. Procedures which reference or change non-local variables represent a partial decomposition of the total task, which is useful for direct with the program environment.
23. ^ O. -J. Dahl; C. A. R. Hoare. Hierarchical Program Structures. C. A. R. Hoare (编). Structured Programming. London, UK: Academic Press. 1972: 175–220. ISBN 978-0122005503. In ALGOL 60, the rules of the language have been carefully designed to ensure that the lifetimes of block instances are nested, in the sense that those instances that are latest activated are the first to go out of existence. It is this feature that permits an ALGOL 60 implementation to take advantage of a stack as a method of dynamic storage allocation and relinquishment. But it has the disadvantage that a program which creates a new block instance can never interact with it as an object which exists and has attributes, since it has disappeared by the time the calling program regains control. Thus the calling program can observe only the results of the actions of the procedures it calls. Consequently, the operational aspects of a block are overemphasised; and algorithms (for example, matrix multiplication) are the only concepts that can be modelled.
24. O. -J. Dahl; C. A. R. Hoare. Hierarchical Program Structures. C. A. R. Hoare (编). Structured Programming. London, UK: Academic Press. 1972: 175–220. ISBN 978-0122005503. useful properties from the standpoint of concept modelling. ……
⑶ Class of instances. In ALGOL 60 a sharp distinction is made between a block, which is a piece of program text, and a dynamic block instance, which is (a component of) a computing process. An immediate and useful consequence is that a block may be identified with the class of its potential activations. (Strictly speaking a "block" in this context means either the outermost block or a block immediately enclosed by a dynamic block instance.) Through the recursion mechanism of ALGOL 60 different instances of the same block may co-exist in a computing process at the same time.
25. ^ . Some History of Functional Programming Languages (PDF). in an invited lecture TFP12, St Andrews University. 12 June 2012 [2022-05-04]. （原始内容 (PDF)存档于2020-04-15）. Algol 60 allowed textually nested procedures and passing procedures as parameters (but not returning procedures as results). The requirement in the copying rule for systematic change of identifiers has the effect of enforcing static (that is lexicographic) binding of free variables.
In their book “Algol 60 Implementation”, Randell and Russell (1964, Sect. 2.2) handle this by two sets of links between stack frames. The dynamic chain links each stack frame, representing a procedure call, to the frame that called it. The static chain links each stack frame to that of the textually containing procedure, which might be much further away. Free variables are accessed via the static chain.
This mechanism works well for Algol 60 but in a language in which functions can be returned as results, a free variable might be held onto after the function call in which it was created has returned, and will no longer be present on the stack.
Landin (1964) solved this in his SECD machine. A function is represented by a closure, consisting of code for the function plus the environment for its free variables. The environment is a linked list of name-value pairs. Closures live in the heap.
26. Ole-Johan Dahl; Bjørn Myhrhaug. The Simula Implementation Guide (PDF). 1967, 1973 [2022-04-17]. （原始内容 (PDF)存档于2022-04-26）. A procedure deviates from a block in that ⑴ it has a name and ⑵ may be referred to at several different places in the program, and ⑶ that parameters may be given to it when invoked. A procedure shares the property of a block that it is impossible to establish a reference to it or to its interior.
27. ^ Peter Naur; et al. Revised Report on the Algorithmic Language Algol 60. [2022-04-14]. （原始内容存档于2007-06-25）. Name replacement (call by name). Any formal parameter not quoted in the value list is replaced, throughout the procedure body, by the corresponding actual parameter, after enclosing this latter in parentheses wherever syntactically possible. Possible conflicts between identifiers inserted through this process and other identifiers already present within the procedure body will be avoided by suitable systematic changes of the formal or local identifiers involved.
. Some History of Functional Programming Languages (PDF). in an invited lecture TFP12, St Andrews University. 12 June 2012 [2022-05-04]. （原始内容 (PDF)存档于2020-04-15）. Algol 60 is not normally thought of as a functional language but its rules for procedures (the Algol equivalent of functions) and variable binding were closely related to those of λ-calculus.
The Revised Report on Algol 60 (Naur 1963) is a model of precise technical writing. It defines the effect of a procedure call by a copying rule with a requirement for systematic change of identifiers where needed to avoid variable capture — exactly like β-reduction.
Although formal parameters could be declared value the default parameter passing mode was call by name, which required the actual parameter to be copied unevaluated into the procedure body at every occurrence of the formal parameter. This amounts to normal order reduction (but not , there is no sharing). The use of call by name allowed an ingenious programming technique: .
28. ^ Peter Naur; et al. Revised Report on the Algorithmic Language Algol 60. [2022-04-14]. （原始内容存档于2007-06-25）. Any occurrence of the procedure identifier within the body of the procedure other than in a left part in an assignment statement denotes activation of the procedure.
29. ^ Peter Naur; et al. Revised Report on the Algorithmic Language Algol 60. [2022-04-14]. （原始内容存档于2007-06-25）. Values of function designators. For a procedure declaration to define the value of a function designator there must, within the procedure declaration body, occur one or more explicit assignment statements with the procedure identifier in a left part; at least one of these must be executed, and the type associated with the procedure identifier must be declared through the appearance of a type declarator as the very first symbol of the procedure declaration. The last value so assigned is used to continue the evaluation of the expression in which the function designator occurs.
30. ^ Peter Naur; et al. Revised Report on the Algorithmic Language Algol 60. [2022-04-14]. （原始内容存档于2007-06-25）. Parameter delimiters. All parameter delimiters are understood to be equivalent. No correspondence between the parameter delimiters used in a procedure statement and those used in the procedure heading is expected beyond their number is the same. Thus the information conveyed by using the elaborate ones is entirely optional.
31. ^ Peter Naur; et al. Revised Report on the Algorithmic Language Algol 60. [2022-04-14]. （原始内容存档于2007-06-25）. Value assignment (call by value). All formal parameters quoted in the value part of the procedure declaration heading are assigned the values ( …… ) of the corresponding actual parameters, these assignments being considers as being performed explicitly before entering the procedure body. The effect is as though an additional block embracing the procedure body were created in which these assignments were made to variables local to this fictitious block with types as given in the corresponding specifications ( …… ). As a consequence, variables called by value are to be considered as nonlocal to the body of the procedure, but local to the fictitious block ( …… ).
32. ^ O. -J. Dahl; C. A. R. Hoare. Hierarchical Program Structures. C. A. R. Hoare (编). Structured Programming. London, UK: Academic Press. 1972: 175–220. ISBN 978-0122005503. A procedure which is capable of giving rise to block instances which survive its call will be known as a class; and the instances will be known as objects of that class. A class may be declared, with or without parameters, in exactly the same way as a procedure ……
33. Kristen Nygaard; Ole-Johan Dahl. The Development of the Simula Languages (PDF). 1978 [2022-03-14]. （原始内容 (PDF)存档于2022-01-20）. the ALGOL-like call by name parameters were out of the question for reasons of security and storage allocation strategy: the actual parameter could be lost during the lifetime of an object. The problem then was to find a name-parameter-like mechanism that would guarantee a safe place for the actual parameter. After much trial and error we hit on the virtual quantity concept where the actual would have to be declared in the object itself, but at a deeper subclass level than that of the virtual specification. Now generalized objects could be defined whose behaviour pattern could be left partly unspecified in a prefix class body. Different subclasses could contain different actual procedure declarations.
34. ^ Ole-Johan Dahl. The Birth of Object Orientation: the Simula Languages (PDF). 2001 [2022-04-13]. （原始内容 (PDF)存档于2021-08-10）. In general attribute identifiers may be redeclared in subclasses, as is the case of inner blocks. The identity of an attribute is determined by the prefix level of the accessing occurrence, or, if the access is remote, by the class qualifying the object reference in question. In this way any ambiguity of identifier binding is resolved textually, i.e at compile time; we call it static binding.
35. ^ Peter Naur; et al. Revised Report on the Algorithmic Language Algol 60. [2022-04-14]. （原始内容存档于2007-06-25）. Function designators define single numerical or logical values which result through the application of given sets of rules defined by a procedure declaration ( …… ) to fixed sets of actual parameters.
36. ^ Peter Naur; et al. Revised Report on the Algorithmic Language Algol 60. [2022-04-14]. （原始内容存档于2007-06-25）. A procedure statement serves to invoke (call for) the execution of a procedure body ( …… ). Where the procedure body is a statement written in Algol the effect of this execution will be equivalent to the effect of performing the following operations on the program at the time of execution of the procedure statement.
37. ^ Kristen Nygaard; Ole-Johan Dahl. The Development of the Simula Languages (PDF). 1978 [2022-03-14]. （原始内容 (PDF)存档于2022-01-20）. In ALGOL, blocks (including procedures) are seen externally as generalized operations. By introducing mechanisms for quasi-parallel sequencing, essentially the same construct could play the role of processes in parallel, and through mechanisms for naming block instances and accessing their contents they could function as generalized data objects. The essential benefits of combining data and operations in a single construct were already there to be explored.
38. ^ Kristen Nygaard; Ole-Johan Dahl. The Development of the Simula Languages (PDF). 1978 [2022-03-14]. （原始内容 (PDF)存档于2022-01-20）. An object would start its life like an instance of a function procedure, invoked by the evaluation of a generating expression. During this phase the object might initialize its own local variables. Then, on passage through the end of the object or as the result of a new basic operation "detach", control would return to the generating expression delivering a reference to the object as the function value. In the former case the object was "terminated" with no further own actions, in the latter case it had become a "detached object" capable of functioning as a "coroutine".
The basic coroutine call "resume (<object reference>)" would make control leave the active object, leaving behind a reactivation point at the end of the resume statement, and enter the referenced object at its reactivation point.
39. ^ Ole-Johan Dahl; Bjørn Myhrhaug. The Simula Implementation Guide (PDF). 1967, 1973 [2022-04-16]. （原始内容 (PDF)存档于2022-04-16）. The procedure "call" is not a part of the Common Base, but is a natural part of a SIMULA 67 Common Base implementation. ……This definition of call is tentative, since the problem is currently being studied by a Technical Committee under the SIMULA Standards Group.
40. ^ O. -J. Dahl; C. A. R. Hoare. Hierarchical Program Structures. C. A. R. Hoare (编). Structured Programming. London, UK: Academic Press. 1972: 175–220. ISBN 978-0122005503. In SIMULA, a coroutine is represented by an object of some class, co-operating by means of resume instructions with objects of the same or another class, which are named by means of reference variables. ……
Thus a main program may establish a coroutine relationship with an object that it has generated, using the call/detach mechanism instead of the more symmetric resume/resume mechanism. In this case, the generated object remains subordinate to the main program, and for this reason is sometimes known as a Semicoroutine. ……
Let X and Y be objects, generated by a "master program" M. Assume that M issues a call (X), thereby invoking an "active phase" of X, terminated by a detach operation in X; and then issues a call (Y), and so forth. In this way M may act as a "supervisor" sequencing a pattern of active phases of X, Y, and other objects. Each object is a "slave", which responds with an active phase each time it is called for, whereas M has the responsibility to define the large scale pattern of the entire computation.
Alternatively the decision making may be "decentralised", allowing an object itself to determine its dynamic successor by a resume operation.
The operation resume (Y), executed by X, combines an exit out of X (by detach) and a subsequent call (Y), thereby bypassing M. Obligation to return to M is transferred to Y.
41. ^ Jaroslav Sklenar. INTRODUCTION TO OOP IN SIMULA. 1997 [2022-02-13]. （原始内容存档于2022-05-11）. The system class Simulation introduces the notion of time. It means that if nested, there will be other local (nested) times.