Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

The struct solution seems OK to me, and the alternatives don't seem to accomplish much, brevity-wise. What's the problem with it?


You 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.


The 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.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: