8分钟
1.2.5 Limbo - Sean Dorward, Phil Winterbottom, Rob Pike, 1995
Limbo(地狱)是用于开发运行在小型计算机上的分布式应用的编程语言,它支持模块化编程,编译期和运行时的强类型检查,进程内基于具有类型的通信管道,原子性垃圾收集和简单的抽象数据类型。Limbo被设计为:即便是在没有硬件内存保护的小型设备上,也能安全运行。Limbo语言主要运行在Inferno系统之上。
Limbo语言版本的“Hello World”程序如下:
implement Hello;
include "sys.m"; sys: Sys;
include "draw.m";
Hello: module
{
init: fn(ctxt: ref Draw->Context, args: list of string);
};
init(ctxt: ref Draw->Context, args: list of string)
{
sys = load Sys Sys->PATH;
sys->print("hello, world\n");
}从这个版本的“Hello World”程序中,我们已经可以发现很多Go语言特性的雏形。第一句implement Hello;基本对应Go语言的package Hello包声明语句。然后是include "sys.m"; sys: Sys;和include "draw.m";语句用于导入其它的模块,类似Go语言的import "sys"和import "draw"语句。然后Hello包模块还提供了模块初始化函数init,并且函数的参数的类型也是后置的,不过Go语言的初始化函数是没有参数的。
学员评价