5.4 3 simple rules for C++ compatible expression code

1. Rule: All variables an constants need a data type

In "normal" mode it is not necessary to define a data type for a variable in Xpressionist. Xpressionist will automatically know if something is a vector, a string or a single floting point value. Not so the GCC compiler. It always needs to know what kind of value a varibale is to compile the script properly.

In Xpressionist you can define a varibale by simply using its name:

a = 10.1; // defines a as a single double precision floting point constant
b = vec( 1, 2, 3 ); // defines be to be a vector constant
c = vec4( 1, 2, 3, 4 ); // defines c to be a vector constant with 4 components
d = "moin"; // define d to be a string

If you try to write an expression with the above convention Xpressionist will give you an error on syntax check if you are in compile mode. For the compiler to work properly you need to first introduce a data type for a variable:

double a = 10.1; // defines a as a single double precision floting point constant
vec b = vec( 1, 2, 3 ); // defines be to be a vector constant
vec4 c = vec4( 1, 2, 3, 4 ); // defines c to be a vector constant with 4 components
string d = "moin"; // define d to be a string

2. Rule: Define all variables at the beginning of your script

As soon as you want to introduce a new variable to your script it is strongly recommended that you define them at the beginninjg of your script. It is a good idea to start an expression to be compiled with a section that defines all variables used in the script.

// defining variables

double a = 10.1;
vec b = vec( 1, 2, 3 );
vec4 c = vec4( 1, 2, 3, 4 );
string d = "moin";

3. Rule: Variables must not be named as objects and vice versa

Never name a variable like an object in your scene. If you have an object called "Cube" your are not allowed to also use a variable named "Cube". Also you must not use objects that are named like Xpressionist defined constants.

Xpressionist 3.5