#6 Constants

brian Wed 7 Dec 2005

Constant fields will just be:

const Pi := 3.14
const Real Pi = 3.14

Constants are implied static finals in Java (and I assume the same for CLR). They have no getter and setter like normal fields. If the constant references a mutable object, nothing will prevent you from changing that object itself, just the constant field variable itself.

We won't make the C# distinction between const vs readonly exactly the same, since we are using readonly for fields to mean don't generate a setter, only a getter. Although the spirit of the semantics is the same.

brian Thu 8 Dec 2005

Just to follow up - we agree that constants will use a naming convention of upper camel case such as Pi or Blue.

Login or Signup to reply.