Appeared in:
Influenced by:
Typing discipline:
File extensions:
Versions and implementations (Collapse all | Expand all):
Programming language

Nemerle (named after archmage from “A Wizard of Earthsea” by Le Guin) is a high-level programming language for .NET platform. It borrows a lot of syntax from C#, and provides object-oriented, functional and imperative features.

Elements of syntax:

Inline comments //
Non-nestable comments /* ... */
Case-sensitivity Yes


Hello, World!:

Example for versions ncc 0.9.3

This example is written in C# style; a more compact version would be just

System.Console.WriteLine ("Hello, World!");
class Hello {
  static Main () : void {
    System.Console.WriteLine ("Hello, World!");

Fibonacci numbers:

Example for versions ncc 0.9.3

This example uses recursive definition of Fibonacci numbers, expressed in functional style. Note the definition of loop counter i — keyword mutable, as opposed to regular def, means that the value of the variable is going to change.

def fib(i)
  | x when x<2 => 1
  | _          => fib(i - 2) + fib(i - 1)
mutable i=0;
while (i<16)
{   System.Console.Write("{0}, ", fib(i));


Example for versions ncc 0.9.3

This example uses recursive factorial definition; tail recursion is optimized by the compiler to become a loop. Note that the default data type is int, so trying to calculate 13! results in overflow error:

Unhandled Exception: System.OverflowException: Number overflow.
def fact(i)
  | 0 => 1
  | other => other * fact(other - 1)
for (mutable i=0; i<16; i++)
    System.Console.WriteLine("{0}! = {1}", i, fact(i));