Wherever the language needs a number, a vector, a colour or a string, it accepts an expression. The parser evaluates it at once, while it reads the file, so an expression can use anything that is declared above it, but nothing that is declared later. This page describes the values (floats, vectors from two to five components, colours, strings, arrays, splines, dictionaries and the identifier types that hold the blocks of the language), the operators that combine them, and the rules for names. The code is in parser_expressions.cpp, parser_strings.cpp and Parse_Declare and Parse_RValue in parser.cpp. The built-in functions are on Functions and constants.
The levels of an expression
The parser reads an expression in layers, from the loosest to the tightest. Which layer it starts at depends on where the expression stands, and that is the main trap of the language.
| Layer | Operators | Where the parser starts here |
|---|---|---|
conditional (Parse_Express) | ? : | inside parentheses ( ... ); the condition of #if, #while and #switch; after rgb, rgbf and the other colour keywords; the argument of one-argument functions such as abs( ) and sin( ) |
| logical | & | | as above |
| relational | < <= = != >= > | as above; strings can be compared as well |
sum (Parse_Rel_Factor) | + - | almost everywhere else: after #declare Name =, as the argument of a keyword (translate, radius ...), as each component inside < >, and as the arguments of functions that take several (str, max, pow ...) |
product (Parse_Num_Term) | * / | |
unary and primary (Parse_Num_Factor) | unary + - !; literals, identifiers, function calls, ( ), < >, . member access |
So a comparison, &, | or ? : must be written inside parentheses unless the place is one of the first group. #declare S = 1 & 1; is a parse error at the &, while #declare S = (1 & 1); is valid. All binary operators of one layer associate to the left. The two logical operators have the same precedence: a | b & c is (a | b) & c. The conditional operator is the exception: it associates to the right, so (0 ? 1 : 0 ? 2 : 3) is 3.
Float expressions
A float is a double-precision number. A literal is written as described on Lexical structure. There is no integer type, no exponentiation operator (use pow), no remainder operator (use mod) and no bit operators (use bitwise_and, bitwise_or and bitwise_xor).
| Precedence | Operator | Meaning |
|---|---|---|
| 1 (tightest) | . | member access, V.x (see below); it applies to the primary before it |
| 2 | unary +, unary -, ! | no change, negation, logical not (1 when the operand is 0, else 0) |
| 3 | *, / | multiplication and division. A division by exactly 0 gives a very large number (HUGE_VAL) and the warning Divide by zero. |
| 4 | +, - | addition and subtraction |
| 5 | <, <=, =, !=, >=, > | comparison; the result is 1 or 0. = is "equal" (there is no ==). The tests for equal, not equal, <= and >= treat numbers that differ by 1e-10 or less as equal |
| 6 | &, | | logical and, logical or; the operands count as true when their absolute value is above 1e-10; the result is 1 or 0 |
| 7 (loosest) | ? : | (cond ? a : b): a when the condition is true, else b. The condition must be a float; the branches may be vectors. Only the chosen branch is used, but both are parsed |
The parser does not know a name for the current value of a variable such as clock: those are the built-in variables of Functions and constants. When a place wants a float and the expression has more than one component, the error is Float expected but vector or color expression found.
#declare A = 2 + 3 * 4;
#declare B = (2 + 3) * 4;
#declare C = 10 - 4 - 3;
#declare D = 12 / 4 / 3;
#declare E = -2 * 3;
#declare F = (1 < 2) + (2 < 1);
#declare G = ((1 = 1) & !(0));
#declare H = (3 > 2 ? 10 : 20);
#declare I = (0 ? 1 : 0 ? 2 : 3);
#debug concat(str(A,0,0), " ", str(B,0,0), " ", str(C,0,0), " ", str(D,0,2), " ", str(E,0,0), " ", str(F,0,0), " ", str(G,0,0), " ", str(H,0,0), " ", str(I,0,0), "\n")
14 20 3 1.00 -6 1 1 10 3.Vector expressions
A vector has two to five components. It is written <a, b>, <a, b, c>, <a, b, c, d> or <a, b, c, d, e>. Each component is a float expression of the sum layer, so a component can hold + - * / and function calls, and a comparison in it needs parentheses (a < would close the vector). The commas between components are optional (<1 2 3> works), and so is white space around them. A vector with a number of components other than 2, 3, 4 or 5 is an error. Most places that want a vector take three components; a float given there is repeated for all three (scale 2 is scale <2, 2, 2>), and a vector with two components is padded with 0 (translate <1, 2> is <1, 2, 0>). A vector of 4 or 5 components where a 3-vector is wanted is the error Vector expected but color expression found.
Operators and promotion
The arithmetic operators work on all components at once. * and / between two vectors multiply and divide component by component; there is no dot or cross operator (use vdot and vcross). When the two operands have different numbers of components, the shorter one is promoted to the length of the longer one before the operation, in one of two ways:
| The shorter operand is | It becomes |
|---|---|
| a float (one component) | the float repeated in every component: 1 + <1, 2, 3> is <2, 3, 4> |
| a vector with two to four components | padded at the end with 0: <1, 2> + <1, 2, 3> is <2, 4, 3> |
The comparison and logical operators also work component by component and give a vector of 1 and 0, but a condition (#if, ?) must be a float.
Built-in vector names
| Name | Value |
|---|---|
x | <1, 0, 0> |
y | <0, 1, 0> |
z | <0, 0, 1> |
t | <0, 0, 0, 1>, the unit vector of the fourth dimension |
u | <1, 0> (two components) |
v | <0, 1> (two components) |
Member access
A dot and a name after a vector or colour takes out one component. Only one component can be taken at a time; there are no multi-letter swizzles such as .xy.
| After the dot | Component | Needs at least |
|---|---|---|
x, u, red | the first | 1 component |
y, v, green | the second | 2 components |
z, blue | the third | 3 components |
t, filter | the fourth | 4 components |
transmit | the fifth | 5 components |
gray | see below | 2 components |
Asking for a component that the value does not have is the error Bad operands for period operator. (for example V.t of a 3-vector). An unknown name after the dot is Expected 'x, y, z, u, v, t or color component'. The names are the reserved words of the same spelling, and x.y style access also works on vector expressions in parentheses ((V * 2).x). .gray is accepted, but in this program it returns the second component, the same number as .green (checked: (0.2, 0.4, 0.9).gray gives 0.4). Where a value has two components the dot names .u and .v are the usual ones, and .x and .y give the same numbers.
The functions that return vectors (vnormalize, vcross, vrotate, vaxis_rotate, vturbulence, trace, min_extent and max_extent) and the ones that take them (vdot, vlength) are on the functions page.
#declare V1 = <1, 2, 3>;
#declare V2 = V1 * 2;
#declare V3 = V1 + <10, 20, 30>;
#declare V4 = V1 * <2, 3, 4>;
#declare V5 = <1, 2> + <1, 2, 3>;
#declare V6 = 1 + V1;
#declare V7 = V1 / 2;
#debug concat(vstr(3,V2,",",0,1), " ", vstr(3,V3,",",0,1), " ", vstr(3,V4,",",0,1), " ", vstr(3,V5,",",0,1), " ", vstr(3,V6,",",0,1), " ", vstr(3,V7,",",0,1), "\n")
#declare W = <1, 2, 3, 4>;
#debug concat(str(W.x,0,0), str(W.y,0,0), str(W.z,0,0), str(W.t,0,0), " ", str(V1.z,0,0), "\n")
#declare U2 = <5, 6>;
#debug concat(str(U2.u,0,0), str(U2.v,0,0), str(U2.x,0,0), str(U2.y,0,0), "\n")
#debug concat(vstr(3, x + y*2, ",", 0, 0), " ", vstr(3, <1,2,3> * x, ",", 0, 0), " ", vstr(4, t, ",", 0, 0), " ", vstr(2, u + v, ",", 0, 0), "\n")
2.0,4.0,6.0 11.0,22.0,33.0 2.0,6.0,12.0 2.0,4.0,3.0 2.0,3.0,4.0 0.5,1.0,1.5, then 1234 3, 5656 and 1,2,0 1,0,0 0,0,0,1 1,1.Colour expressions
A colour holds five numbers: red, green, blue, filter and transmit. Filter and transmit are what makes an object partly see-through: transmit lets light through unchanged, and filter lets it through tinted by the colour. A colour is an expression of its own kind, and it starts with a colour keyword or a colour identifier. Everywhere else a colour is a vector of five components, and a vector with five components is a colour.
| Form | Meaning |
|---|---|
rgb v | red, green and blue from a vector (or a float repeated three times); filter and transmit are 0. rgb 0.5 is a grey |
rgbf v | four values: red, green, blue, filter; a single float is repeated four times |
rgbt v | four values: red, green, blue, transmit |
rgbft v | five values: red, green, blue, filter, transmit |
srgb, srgbf, srgbt, srgbft v | the same, with red, green and blue given in the sRGB scale; the parser converts them to the working gamma of the scene (the error Cannot parse sRGB colors before assumed_gamma has been set. if assumed_gamma is not set yet) |
red, green, blue, filter, transmit f | sets one component; they can follow each other and the others stay 0: color red 1 green 0.5 filter 0.2 |
alpha f | a discontinued name of filter (a warning for old language versions) |
color or colour | an optional word in front of the forms above |
| a colour identifier, or a 5-component vector | the five values as they are |
After the first keyword (rgb and the like), the expression that follows is a full expression of the conditional layer. The colour keywords themselves cannot appear inside it: rgb <1, 0.5, 0> * 0.5 + rgb 0.25 is an error (Expected 'numeric expression', color keyword 'rgb' found instead). To do arithmetic on colours, put them in identifiers first. A colour identifier in an expression is a vector of five components, so Orange * 0.5 + Grey works component by component, and so does adding a colour and a plain 5-vector.
Pitfalls
color 0.5(a float after the wordcolor, with norgb) is promoted to all five components, so filter and transmit are 0.5 as well, and the parser warns:Float value promoted to full color vector where both filter and transmit >0.0.Writergb 0.5.rgbf 0.5gives 0.5 in red, green, blue and filter;rgb 0.5gives 0 in filter and transmit.- Where only red, green and blue are used (a light colour, for instance), a nonzero filter or transmit is dropped with the warning
Expected pure RGB color expression, unexpected filter and transmit components will have no effect. - With
assumed_gamma 1,srgb <0.5, 0.5, 0.5>becomes 0.214 in each component. .graydoes not give the grey value (see Member access).
#declare Col = rgbft <0.1, 0.2, 0.3, 0.4, 0.5>;
#debug concat(str(Col.red,0,1), str(Col.green,0,1), str(Col.blue,0,1), str(Col.filter,0,1), str(Col.transmit,0,1), "\n")
#declare Orange = rgb <1, 0.5, 0>;
#declare Grey = rgb 0.25;
#declare Col2 = Orange * 0.5 + Grey;
#debug concat(vstr(3, Col2, ",", 0, 3), "\n")
#declare Col3 = rgbf 0.5;
#declare Col4 = rgb 0.5;
#declare Col5 = color red 1 green 0.5 filter 0.2;
#debug concat(vstr(5, Col3, ",", 0, 1), " ", vstr(5, Col4, ",", 0, 1), " ", vstr(5, Col5, ",", 0, 1), "\n")
#declare Col7 = srgb <0.5, 0.5, 0.5>;
#debug concat(vstr(3, Col7, ",", 0, 4), "\n")
#declare C4 = <1, 0.5, 0.25, 0.1, 0.2>;
#debug concat(vstr(5, C4, ",", 0, 1), " ", str(C4.filter,0,1), " ", str(C4.transmit,0,1), "\n")
0.10.20.30.40.5, 0.750,0.500,0.250, 0.5,0.5,0.5,0.5,0.0 0.5,0.5,0.5,0.0,0.0 1.0,0.5,0.0,0.2,0.0, 0.2140,0.2140,0.2140 and 1.0,0.5,0.2,0.1,0.2 0.1 0.2. The five-component vector is a colour.String expressions
A string is a sequence of 16-bit characters. A literal is written in double quotes, with the escapes of Lexical structure. Strings have no operators; they are built by functions. Any place that wants a string takes any of the expressions below, so #include, #debug, image file names and text objects accept a concat(...). A number must be turned into a string with str or vstr; concat("a", 1) is an error.
| Expression | Result |
|---|---|
"text" | the literal |
concat(s1, s2, ...) | the strings joined; at least one argument |
str(f, width, decimals) | the float as text, in C %f format. A width above 0 pads with spaces on the left; a negative width pads with zeros to that width; 0 gives no padding. A decimals of 0 or more is the number of digits after the point, and a negative value leaves the default of six |
vstr(n, vector, sep, width, decimals) | the first n components of the vector (n is made to fit 2 to 5), each as in str, with the string sep between them |
chr(n) | the one-character string with code n, from 0 to 65535 (otherwise Value n cannot be used in chr(...).) |
substr(s, start, length) | part of s; start counts from 1. Going beyond the end is the error Illegal parameters in substr. |
strupr(s), strlwr(s) | the string in upper or lower case |
datetime(days [, "format"]) | a date and time in UTC. days counts from 2000-01-01 00:00:00 (as now does); the format is a C strftime format, by default %Y-%m-%d %H:%M:%SZ. An empty format, an invalid one, or a result of 200 characters or more is an error |
| a string identifier | the stored string |
The functions that take strings and give numbers are strlen, strcmp, asc and val (see the functions page). strcmp returns the difference of the first two characters that differ (counting the end of the string as 0), so it is negative, zero or positive, and not just -1, 0 and 1. In a conditional-layer expression, two strings can be compared with <, <=, =, !=, >= and >; the result is a float. An expression that starts with a string is parsed as a string comparison.
#debug concat("[", str(3.14159, 8, 2), "] [", str(3.14159, -8, 2), "] [", str(3.14159, 0, 0), "] [", str(3.14159, 0, -1), "] [", str(42, 4, 0), "]\n")
#debug concat(vstr(3, <1,2,3>, " | ", 5, 1), "\n")
#debug concat(chr(65), chr(97), " ", str(asc("A"),0,0), " ", str(asc(""),0,0), "\n")
#debug concat(substr("Hello world", 7, 5), "|", substr("Hello", 1, 0), "|", strupr("abc"), strlwr("DEF"), "\n")
#debug concat(str(strlen("hello"),0,0), " ", str(strcmp("a","b"),0,0), " ", str(strcmp("b","a"),0,0), " ", str(strcmp("a","a"),0,0), " ", str(strcmp("a","c"),0,0), " ", str(strcmp("abc","ab"),0,0), "\n")
#debug concat(str(val("12.5abc"),0,2), " ", str(val("abc"),0,2), " ", str(val("1e2"),0,0), "\n")
#debug concat(datetime(0), " | ", datetime(1.5), " | ", datetime(366, "%A %d %B %Y"), " | ", datetime(0.25, "%H:%M"), "\n")
#declare Cmp1 = ("apple" < "banana");
#declare Cmp2 = ("abc" = "abc");
#declare Cmp3 = ("b" != "a");
#debug concat(str(Cmp1,0,0), str(Cmp2,0,0), str(Cmp3,0,0), "\n")
[ 3.14] [00003.14] [3] [3.141590] [ 42], 1.0 | 2.0 | 3.0, Aa 65 0, world||ABCdef, 5 -1 1 0 -2 99, 12.50 0.00 100, 2000-01-01 00:00:00Z | 2000-01-02 12:00:00Z | Monday 01 January 2001 | 06:00 and 111.Arrays
An array is declared with #declare or #local. It has one or more dimensions, and its elements are values of any identifier type. By default all elements must have the same type: the first element that is assigned fixes the type, and assigning another type is the error Attempted to redefine float identifier as string identifier. The word mixed removes that rule.
| Form | Meaning |
|---|---|
array[n], array[n][m] ... | a fixed-size array with that many elements in each dimension. An array has at most five dimensions (Too many array dimensions beyond that), and a size of 0 or below is an error. A size is a float rounded down after adding 1e-10 |
array[n] { v1, v2, ... } | with initial values. For a second dimension, nested braces: array[2][3] { {1,2,3}, {4,5,6} }. The number of initialisers must match the size, and a value may be left out with optional before the braces |
array { v1, v2, ... } | a resizable one-dimensional array with as many elements as there are values |
array | an empty resizable array; assigning to A[4] grows it to 5 elements |
array mixed [n] | an array whose elements may have different types |
A[i], A[i][j] | element access. The index is a float expression; a negative one is Negative subscript and one past the end of a fixed array is Array subscript out of range. Reading an element that has no value is Attempt to access uninitialized array element. |
dimensions(A), dimension_size(A, d) | the number of dimensions, and the size of dimension d (counting from 1) |
An array element can be an array (an array of arrays is built by assigning arrays to elements). An element of an array that holds objects, colours and so on is used like any identifier of that type, with member access where it applies: Colours[1].green. #ifdef (A[i]) and defined(A[i]) test whether an element has a value. A one-dimensional array can be unpacked into names with #declare { A, B, C } = Array;.
Dictionaries
A dictionary is a table of named values. dictionary { .name: value, ["key"]: value } makes one. Entries are read with Dict.name or Dict["key"], where the key is a string expression, and are assigned with #declare Dict.name = value;. A dictionary can hold dictionaries (Nested.inner.x), arrays, objects and any other identifier type. Reading an entry that does not exist is the error Attempt to access uninitialized dictionary element.; defined(Dict.name) tests for it. #local cannot assign a dictionary entry that lives in a table that is not local (Cannot use '#local' to assign a non-local array or dictionary element.).
The words local and global stand for the tables of the current scope and of the global scope: local.X reads the X of the top table, and global.X the global one, even when a local X hides it.
#declare Q = array[2][3] { {1,2,3}, {4,5,6} };
#debug concat(str(Q[1][2],0,0), " ", str(dimensions(Q),0,0), " ", str(dimension_size(Q,1),0,0), " ", str(dimension_size(Q,2),0,0), "\n")
#declare D1 = array { 1, 2, 3 };
#declare D2 = array;
#declare D2[4] = 7;
#debug concat(str(dimension_size(D1,1),0,0), " ", str(dimension_size(D2,1),0,0), " ", str(D2[4],0,0), " ", str(defined(D2[1]),0,0), "\n")
#declare Mx = array mixed [3];
#declare Mx[0] = 1; #declare Mx[1] = "two"; #declare Mx[2] = <1,2,3>;
#debug concat(str(Mx[0],0,0), Mx[1], vstr(3, Mx[2], ",", 0, 0), "\n")
#declare Colours = array[2] { rgb <1,0,0>, rgb <0,1,0> };
#debug concat(str(Colours[1].green,0,0), "\n")
#declare Dict = dictionary { .alpha: 1, .beta: "two", ["gamma"]: <1,2,3> };
#debug concat(str(Dict.alpha,0,0), Dict.beta, vstr(3, Dict.gamma, ",", 0, 0), " ", str(defined(Dict.delta),0,0), "\n")
#declare Dict.delta = 4;
#debug concat(str(Dict.delta,0,0), " ", str(Dict["delta"],0,0), "\n")
#declare Nested = dictionary { .inner: dictionary { .x: 5 } };
#debug concat(str(Nested.inner.x,0,0), "\n")
#declare G1 = 10;
#macro M1()
#local G1 = 20;
#debug concat(str(G1,0,0), " ", str(global.G1,0,0), " ", str(local.G1,0,0), "\n")
#end
M1()
6 2 2 3, 3 5 7 0, 1two1,2,3, 1, 1two1,2,3 0, 4 4, 5 and 20 10 20.Splines
A spline identifier holds a curve through a list of points. It is declared with spline { ... } and is evaluated like a function: S(t) gives the point at parameter t. The parser marks splines as an experimental feature and prints a warning when a scene uses one (This rendering uses the following experimental feature(s): spline.). These splines are values of the language; the splines that shapes such as lathe and prism read are described with those objects.
| Form | Meaning |
|---|---|
spline { [type] t1, point1, t2, point2, ... } | a spline through the points. Each entry is a parameter value (a float), then a point of one to five components (a float is a one-component point). At least one entry is needed (Spline must have at least one entry.); a point with more than five components is an error |
linear_spline | the type: straight lines between the points (the default) |
quadratic_spline | the type: a quadratic curve |
cubic_spline | the type: a Catmull-Rom cubic curve through the points |
natural_spline | the type: a natural cubic spline |
spline { Old t, point, ... } | adds entries to an existing spline identifier; a type word after Old changes the type |
S(t) | the value at t. The result has as many components as the largest point of the spline, but at least two: a spline of plain floats returns two-component vectors that repeat the value, so use .x to get a float |
S(t, type) | evaluates a copy of the spline as the given type (linear_spline, quadratic_spline, cubic_spline or natural_spline) |
The words bezier_spline and b_spline are not accepted in a spline value; they belong to the shapes that take splines (sphere_sweep, prism, lathe and sor).
#declare S = spline { cubic_spline 0, <0,0,0>, 1, <1,2,0>, 2, <3,1,0>, 3, <4,4,0> }
#debug concat(vstr(3, S(1.5), ", ", 0, 4), "\n")
#debug concat(vstr(3, S(1.5, linear_spline), ", ", 0, 4), "\n")
#declare M = spline { S 4, <5,5,0> }
#debug concat(vstr(3, M(3.5), ", ", 0, 4), "\n")
#declare T1 = spline { linear_spline 0, 1, 1, 5 }
#debug concat(vstr(2, T1(0.5), ", ", 0, 2), "\n")
2.0000, 1.4375, 0.0000, 2.0000, 1.5000, 0.0000, 4.5000, 4.5000, 0.0000 and 3.00, 3.00.Identifier types
Every identifier has a type, and the type is that of the value it was declared with. The parser keeps the type as a token (the *_ID_TOKEN list at the end of Reserved words). A #declare or #local decides the type from what follows the =. An identifier can be used wherever the block that it holds can stand: pigment { P1 }, texture { T }, object { O }. Most blocks accept more items after the identifier, which then change a copy: texture { Tx1 scale 2 }.
| Type | Declared with | Used where |
|---|---|---|
| float | an expression of one component | everywhere a float is wanted; also as a one-component vector (promoted) |
| 2D vector | an expression of two components (<a, b>) | UV vectors, and wherever a vector is wanted (padded with 0) |
| vector | three components | locations, directions, scale and so on |
| 4D vector | four components | where four components are wanted (the slice of a julia_fractal); in arithmetic with other vectors |
| colour | rgb ... and the other colour forms, or an expression of five components | wherever a colour is wanted; in arithmetic as a five-component vector |
| string | a string expression | wherever a string is wanted |
| array | array ... | with [ ]; dimensions; unpacking with #declare { A, B } = Array |
| dictionary | dictionary { ... } | with .name or ["key"] |
| function (float result) | function ( ... ) { ... } | called like f(x, y, z); as the pattern or surface of isosurface, parametric and function patterns (see the functions page) |
| function (vector result) | function { transform { ... } }, function { spline { ... } } or function { pigment { ... } } | called like f(x, y, z); the result is a vector (three components for a transform, two to five for a spline, a colour for a pigment) |
| spline | spline { ... } | called like S(t) |
| transform | transform { ... } | transform T after an object, texture or pattern, inside another transform { } |
| pigment | pigment { ... } | pigment { P } in a texture or object |
| normal | normal { ... } | normal { N } |
| finish | finish { ... } | finish { F } |
| texture | texture { ... } (one or several layers one after the other) | texture { T } |
| interior | interior { ... } | interior { I } |
| media | media { ... } | media { M } in an interior or at the top level of the scene |
| density | density { ... } | density { D } in a medium |
| material | material { ... } | material { M } on an object |
| camera | camera { ... } | camera { C } |
| object | any shape, CSG or mesh block | object { O }, as part of a CSG, with modifiers after it |
| fog, rainbow, sky_sphere | fog { ... }, rainbow { ... }, sky_sphere { ... } | the block of the same name |
| colour_map, pigment_map, slope_map, density_map, normal_map, texture_map | the block of the same name | after a pattern, where a map is wanted |
| macro | #macro | called as Name(...) |
| file | #fopen | in #read, #write and #fclose |
| parameter | a macro argument that is an identifier | inside the macro, as the identifier it stands for |
#declare Tr = transform { rotate y*90 translate <1, 0, 0> }
#declare Tr2 = transform { Tr scale 2 }
#declare P1 = pigment { rgb <1, 0, 0> }
#declare F1 = finish { diffuse 0.7 }
#declare N1 = normal { bumps 0.3 }
#declare Tx1 = texture { pigment { P1 } finish { F1 } normal { N1 } }
#declare Tx2 = texture { Tx1 scale 2 }
#declare Ball = sphere { 0, 1 texture { Tx2 } }
object { Ball transform Tr2 }
object { Ball translate x*3 pigment { P1 } }
#debug concat(str(defined(Tr),0,0), str(defined(Ball),0,0), "\n")
11. The declarations of blocks need no semicolon.Scope and lookup
A name is looked up in the symbol tables from the top of the stack down, so a local name hides a global one of the same spelling. The tables, the rules for #declare and #local, and the effect of macros and include files are on Preprocessor directives. Three points matter for expressions:
- A float, vector or colour identifier that is the whole argument of a macro call is passed as an alias of the caller's identifier. Everything else is evaluated first, and the macro gets a copy.
#declare B = A;with a single identifier on the right copies the value; later changes ofAdo not changeB.- An identifier of a block type holds its own copy of the block.
object { Ball translate x*3 }changes the copy that this use makes, notBall.
The names clock, clock_on, pi, tau, version, true and the like are reserved words, not identifiers, so they cannot be redeclared. The names frame_number, clock_delta, image_width and the other animation and image variables are ordinary float identifiers that the front end declares before the parse starts; they can be hidden or redeclared like any float (see the functions page).
Not described
Known, not yet covered
- Reference: the contents of each block type (what goes inside
pigment { },texture { }and so on) are described on the pages for those blocks, not here.