Disabling allocations

I think I am not the only one who proposes the “single dispatch” problem. Of course, one can use NameTuple and FunctionWrapper to mimic a method table just like those in C++ (actually I have tried a prototype of it, but I finally gave up for complexity).
The problem here is that we try to eliminate dynamic dispatch, since dynamic dispatch is inefficient and allocates memory, whereas single dispatch in C++ and other languages also happens at runtime but the cost of single dispatch is much smaller.

It’s solvable, but the solution is frustrating. For example, Elrod suggests using only one light type. It’s doable in this toy projects and this is what I currently done in this project. But it won’t work well when you have a lots of light types. He also suggests that ensuring the production of different types followed immediately by the consumption of the types by using a if-elseif-else branching. However, for a raytracer, this is impossible, since when you create a list of lights for the scene, different type of lights are already mixed together. It’s also possible to use a large union of different types and let the compilers do the union splitting. But I don’t think this approach scales well…You have to modify the code of library to add more supports of different type.