Alice (programming language)
This article needs additional citations for verification. (February 2011) |
Paradigm | Multi-paradigm: imperative, functional, distributed, concurrent |
---|---|
Designed by | Saarland University |
First appeared | 2000 |
Stable release | 1.4
/ May 3, 2007 |
Typing discipline | strong, static, inferred |
OS | Cross-platform |
Website | Alice, DE: University of Saarland |
Influenced by | |
ML, Oz |
Alice ML is a functional programming language designed by the Programming Systems Lab at Saarland University. It is a dialect of Standard ML, augmented with support for lazy evaluation, concurrency (multithreading and distributed computing via remote procedure calls) and constraint programming.
Overview
Alice extends Standard ML in a number of ways that distinguish it from its predecessor.
Example
Alice extends Standard ML with several primitives for lazy evaluation and concurrency. For example, threads may be created using the spawn keyword. Consider the naive algorithm for computing the Fibonacci numbers:
fun fib 0 = 0 | fib 1 = 1 | fib n = fib(n-1) + fib(n-2);
For large values of n
, fib n
will take a long time to compute. This computation can be performed in a separate thread by
val x = spawn fib n;
The variable x
is now bound to a so-called "future". When an operation requires the actual value of x
, it blocks until the thread is done with the computation. To exploit parallelism one could even define fib as follows:
fun fib 0 = 0 | fib 1 = 1 | fib n = spawn fib(n-1) + fib(n-2);