Hacker News new | ask | show | jobs
by jcranberry 1544 days ago
Sum types are often used in cases where the type is unknown at run time. In C++ the analog would be std::variant. In Rust it would be enums. In Haskell its algebraic data types.

A first class sum type in c++ ala Rust or Haskell would certainly be appreciated, as the clunkiness of std::variant/std::visit is a well known annoyance.

1 comments

Could you expand on your first sentence? I don't understand what do you mean that sum types are used when the type is unknown at runtime.
They meant unknown at compile-time, not run-time.