Why does this function not compile?

BlitzMax Forums/BlitzMax Programming/Why does this function not compile?

DJ Scantron(Posted 2006) [#1]
It gives me an error: Expecting ')' but encountered '['

Function CompNormal:Float[] (vertex1:Float[3], vertex2:Float[3], vertex3:Float[3])

Local tempve1:Float[3], tempve2:Float[3]
tempve1[0] = vertex1[0] - vertex2[0]
tempve1[1] = vertex1[1] - vertex2[1]
tempve1[2] = vertex1[2] - vertex2[2]

tempve2[0] = vertex2[0] - vertex3[0]
tempve2[1] = vertex2[1] - vertex3[1]
tempve2[2] = vertex2[2] - vertex3[2]

vertex1[0] = tempve1[0] * tempve2[0]
vertex1[1] = tempve1[1] * tempve2[1]
vertex1[2] = tempve1[2] * tempve2[2]

Local vlen:Float = Abs Float(Sqr(vertex1[0] * vertex1[0] + vertex1[1] * vertex1[1] + vertex1[2] * vertex1[2])) ''vector length
vertex1[0] = vertex1[0] / vlen
vertex1[1] = vertex1[1] / vlen
vertex1[2] = vertex1[2] / vlen

Return vertex1

End Function

I don't understand why.


Jim Teeuwen(Posted 2006) [#2]
its because of the line:
Function CompNormal:Float[] (vertex1:Float[3], vertex2:Float[3], vertex3:Float[3])


You can't have Size initializers in the method or function description. So 'blah:float[234]' is illegal.

try:
Function CompNormal:Float[] (vertex1:Float[], vertex2:Float[], vertex3:Float[])

And then check if the array's are of proper length inside the function.

If( vertex1.Length < 3 Or vertex2.Length < 3 Or vertex3.Length < 3 ) Then
	Throw "Arguments are not of the expected size."
End If



DJ Scantron(Posted 2006) [#3]
Cool, thanks.