define: Define a Global Constant

A global constant lets you associate a name with a constant value in your simulation. The @define directive allows you to associate names with ints, floats and strings.

These constants can be very useful when you have the same value used several times in a simulation—then if you wanted to change the value, instead of making the change several times, you would make it once in the @define directive. They can also be useful for assigning meaningful symbols to numbers in your simulation. For example, if your cellular automata is arbitrarily chosen to be 50x50, then instead of hardcoding the number 50, it is more flexible and more descriptive to use a global constant.

Global constants are defined with the following form:

@define constant-name constant-value .

Here are some examples:

@define CA_SIZE                 50.
@define PI_VALUE                3.14159.
@define STRING_CONSTANT         "Hello".

By setting these constants at the top of the source file, you can use them later on. For example:

+ to print-pi:
        print "pi is approximately: ", PI_VALUE.

It is not required, but, by convention, global constants are typically written with all capital letters, to distinguish them from variables.