|
 |
The reference manual (section 3.3.1.8.3, or 2.3.1.8.3 in the wiki) gives
the following as a legal function definition:
#declare foo3 = function(k1, k2, z, y) { x + y * z + k1 * y + k2 }
The function body refers to x, even though x is not one of the declared
arguments. But the function still works, somehow. The following scene
----------[BEGIN SCENE]----------
#version max (3.5, min (3.8, version));
global_settings { assumed_gamma 1 }
#declare foo3 = function(k1, k2, z, y) { x + y * z + k1 * y + k2 }
#declare G = foo3 (1, 2, 3, 4);
#debug concat ("G = ", str (G, 0, 1), "\n")
-----------[END SCENE]-----------
yields the output:
G = 18.0
Manually working through the function yields
x + y * z + k1 * y + k2
= x + 4 * 3 + 1 * 4 + 2
= x + 12 + 4 + 2
= x + 18
This suggests that POV-Ray pre-assigned 0 to x. That this construction
is given as an example suggests that this is a significant feature
(however inadvisable to use), and not just a parser glitch. Shouldn't
there be some explanation of this feature?
Post a reply to this message
|
 |