Strange way to recover performance with polymorphic types

Thanks very much for your detailed reply and possible solutions. I am afraid that none is really fully satisfactory solution.

This is really interesting and useful in other cases I have. I did attempt to annotate the actual definition of each extent function but it did not have any effect. In any case, there is still one allocation per call and is not the case when calling extent_.

I cannot do this since in the complete problem I do have a nested hierarchy of figures and I would require an heterogeneous vector of concrete figures. See the initial thread.

I will try this one providing that the limit is 16 or higher, although it suffers from the limitation that the module will no be extendable with additional figures provided by a client of the module.
I wonder if Union{Box, Circle, SBox, SCircle, Triangle,AbstrcatShape} would allow me to add later additional shapes.

1 Like