3 ms·
The need for an open sum tends to be vanishingly rare in my experience.
by chongli 13y ago
The need for an open sum tends to be vanishingly rare in my experience.
- dllthomas 13y agoIt occurs moderately frequently in libraries where a user should be able to define domain specific types along with how the library should treat those types. A classic example would be a raytracer where the user might be adding new kinds of scene elements. It probably shouldn't occur in application code. For what it's worth, I do think people underestimate the applicability of closed sum types.
- chongli 13y agoI'm aware of the raytracer library example. The solution to that is to not use types to represent shapes. Instead, classify shapes by primitive types (triangles, quads, bezier curves, NURBS, etc.) and use a closed sum for those. It's far less common for a user to want to create a new primitive type and you can always use an escape hatch in the closed sum that allows the user to define their own primitive along with a function to draw it in terms of one of the other primitives.
- dllthomas 13y agoThis thread got silly a while back. I'm abandoning it.