2 ms·
The struct solution seems OK to me, and the alternatives don't seem to accomplish much, brevity-wise. What's the problem with it?
by AlexCoventry 9y ago
The struct solution seems OK to me, and the alternatives don't seem to accomplish much, brevity-wise. What's the problem with it?
- xwvvvvwx 9y agoYou would need the lambdas if you wanted to capture state from outside the visitor. But I agree, the struct seemed fine (not amazing, but good enough) to me.
- humanrebar 9y agoThe struct solution is a design pattern for creating a sum type. The lambda solution is a factory for creating any sum type as long as the parameter in each lambda is unique. Among other things, it's a design with weaker coupling.