Spec-Zone .ru
спецификации, руководства, описания, API

def and var

Variables are declared with two keywords: def and var. Variables which are defined once, and are never assigned-to, are defined with def.

def Z0 = 376.730313;

Note that a bound variable (without inverse) is defined once and can never be assigned. It should also be declared with def:

def x = bind y + z;

See the Binding chapter.

Variables that will or can be assigned-to should be declared with var:

var x = 0; 
++x;

Be sure to use def when the intent is that it is a definition which will not change. Doing so is a useful tool that allows the compiler to generate more efficient code and to better check the correctness of programs. Using def is also important for readers of this code (or documentation generated from it) helping them understand what can change, and what cannot.