Version: 4.2.4.2
1 Introduction
In the field of computer science, we have various model of computation
(such as turing machine and lambda calculus), and we have various
programing languages. In the real word, we have all sorts of computing
machine. So the basic question is: whether our programing language
(all model of computation can be seem as a programing language) models
the physical machine appropriately? Surprisingly, the answer for most
programing language/model of computation is no: the mismatch is
resources, for example, number of memory. All physical computing
machine, already build or to be build/designed, only had/has/will have
a limit amount of memory. But most of the programming language/model
of computation give a false illusion of unlimited resource (there’s a
few exceptions, which we will talk in the related work part): Turning
machine requires an infinite tape; Cellular automaton assume an
unlimited space; On the programming language side, the stack might
overflow, but it’s not part of the language specification; for
language without automatic memory management, e.g. C, a malloc call
might fail, but most of the time programmers are not aware of that;
for garbage collected language, e.g. PLT Scheme, there’s even less
information for a user when an underlining (inside) call to malloc
fails.
Here I implemented a resource limited version of Scheme. The philosophy
is that, the programmer, when coding, should be aware of resource usage,
and is forced to explicitly express that.
2 Usage
The same as scheme or scheme/base, but with
resource limit on all functions.
(lambda secs mb arg body ...+) |
|
|
The resource-limited lambda.
secs and
mb are the time limit (in
seconds) and memory limit (in megabytes). Both can be either a real number or
a procedure that takes the same argument as the function and returns a real number
as the limit value. The procedure calls
call-with-limits to do the actually limit.
(let loop secs mb ([id init-expr] ...) body ...+) |
|
|
The resource-limited let loop. The
([id init-expr] ...) body ... part is the same as in normal Scheme.
Normal let binding is unchaged.
(limited-do secs mb | ([id init-expr . step-expr-maybe] ...) | (stop?-expr finish-expr ...+) | expr ...+) |
|
The resource-limited do.
(define (head secs mb args) body ...+) |
|
head | | = | | id | | | | | | (head secs mb args) |
|
The define form that works with limit values.