Using Data Items
 
 
 

Once a variable has been declared, it may be referenced. The reference to a variable may occur in the sense of retrieval, where the variable may be thought of as a source of values to be used. When referenced in this way, a variable behaves as though a corresponding literal had been used in place of the reference. This usage of variables is permitted anywhere in SDL, providing the variable being referenced has already been declared. Thus, it is possible to declare a <scalar>:

	scalar max_color(255);

Then immediately use it to declare another variable, for example

	triple white( max_color, max_color, max_color );

Indeed, this is exactly how normal use of SDL will proceed, with the declaration of basic building blocks followed by even larger pieces until all the items needed for the model have been defined. Thus, variables of the elementary data types (that is, scalar, triple, CV, filename, shader, texture, array) will commonly be refer-enced as part of the declaration of other variables, or in the specification of liter-als. References to vari-ables of the data types for “primitive objects” (that is, light, patch, face) will normally be in the MODEL section of SDL where they will be used to create an instance of the object represented by the variable. Some of the data types provided in SDL are complex compositions of many com-ponents.

Some operations are defined for all data types, while other operations depend upon the data type. There are common operations which are allowed for vari-ables of all data types except as noted below. These common operations are:

An exception to the above is that there is no such thing as a literal (to serve as the source of an assignment) for some data types, namely: shaders and transforma-tions. Note that printing means that the values of the components defining the variable will be output to “stderr”, not that some graphic rendition will be at-tempted. Note that operations on a scalar are the same as previous versions of SDL. This includes general usage in arithmetic expressions (see “expressions” be-low). While there is no such thing as a literal transformation, a variable of type transformation can have the cur-rent model transform assigned to it.

Arrays are special. While the above operations are valid and true for arrays, they don’t give the full picture. Therefore, the operations will be reconsidered here for ar-rays.