Oh, I think you are new to OOP :)
You should read some articles about it.
I will start from beginning.
The full syntax for declaring local variables is following:
def <name> [: <type>] = <initializer>;
mutable <name> [: <type>] [= <initializer>];
inside [] is optional.
so you can write one of the following:
def a = 1; // This is same as below but compiler infers type
def a : int = 1; // Write time by ourselves
mutable a; // Initialized to default
mutable a : int; // Initialized to default but with type specified
mutable a = 0; // Same
mutable a : int = 0; // Same
As you can see compiler can also infer type from the usage:
mutable x;
x = "";
x.GetType() == "string"
This is the power of Nemerle :)
On the other hand, fields are part of the class, meaning part of the interface.
The decision that there is no type inference for fields (only in some special cases), because it can simply break others code.
So in fields you always specify type and you can also specify public/private/protected/internal access.
class A
{
// This defines immutable fields
public x; // Invalid
public x : int; // OK
public x : int = 10; // We can init here or in constructor
// Mutable fields, same syntax but adding mutable before name
mutable y : int;
}
The difference between mutable and 'def' (immutable) that you cannot change the value after you initialize it.
Example:
def a = 1;
a = 2; // Error
mutable a = 1;
a = 3; // OK
On the other hand each def creates new scope so you can write the following:
def a = 1;
def a = 2; // this 'a' is not same as first 'a'.
In Nemerle you should use more 'def' than 'mutable' , this helps you writing more maintainable and readable code.
Good luck with learning Nemerle. It is great language :)