I’m able to parse a minimal form of fractal formula files. When I tried to run it on the full formula directory, I found the remaining features that I needed to implement.
Some parameters return function names, which are called indirectly by the code. Very slick. I have to be able to implement this, which shouldn’t be a problem. A parameter can return any of the following functions, which means I also have to implement this in the shading language: sin, sinh, asin, asinh, cos, cosh, acos, acosh, tan, tanh, atan, atanh, cotan, cotanh, sqr, sqrt, log, exp, abs, cabs, conj, flip, ident, zero, recip, ceil, floor, trunc, round.
Fuck….. I can look up the trig functions for complex values, but I don’t know what ‘floor’ and ‘ceil’ are supposed to do with complex numbers. I supposed they just get executed on each component…..
Good reference for complex trancendental functions here. Complex asin and acos were kind of hard to find, but I found references here and here respectively. More here.
I implemented all the functions in the math library. Now I have to put in hooks for all of them in the expression library and the shading language. 29 complex functions in all. It should get done within a few days.
Also have to start thinking about how to deal with the indirect function calling. Have to modify the grammar to be able to handle things like @funcName(z) , @funcName(z, zz) stuff like that. So basically, we have to be able to handle expression(expression). The first expression needs to be callable. This could be interesting, since constructors should be handled this way. Currently, Double() is a function, but it should be a proper constructor, parameterized by its type. Ctor could be a meta-object type, that takes a type (or a type string) as an argument. Then, when its called, it just preforms the constructor as a function.
So basically, I have to have the expression grammar be able to handle objects being callable, in addition to regular functions being callable. The spa::Value needs to have a mechanism for being able to resolve its own indirect function calls.
This is getting interesting. This feature would push the grammar to become more object oriented, as opposed to being strictly functional. It was on my to-do list, but I guess it has to happen sooner than later.
Another thing to consider is the dot operator. For doing things like object.method(). This would be calling a method on an object as opposed to just evaluating an object as a function. It would help to be able to see a c-grammar to see what precedence order the ‘.’ takes w.r.t. other operators.