You are likely to find your programs using some values which
are never intended to change. For example, pi has been
3.14159265... for a very long time, despite the best
efforts of biblical writers and American legislators to
change it to a more convenient value.
You may aid both human and mechanical readers of you code by explicitly declaring such values to be constants: This saves human readers the work of deducing that they never change, and allows compilers to produce more efficient code by omitting checks to see if the value has changed.
The Muq MUF syntax for establishing a constant is
3.1416 -->constant pi
This does everything that
3.1416 --> pi
does, and then in addition sets a flag making it an error to modify this value. (This flag is currently implemented by setting the function value of the symbol to zero, but you should not write code to depend on this fact, nor is it immediately visible.)
You may actually change the value of such a constant using
-->constant instruction, but this exception
is intended only to simplify reloading a source file after
editing it: Using this to modify a constant inside a program
is likely to have unexpected effects unless you are very
careful to subsequently recompile all code which "knows" the
value of the constant.
Go to the first, previous, next, last section, table of contents.