Meta:

What if we had an "opDestructure" or "opMatch" or something like that? It could return a tuple and be auto-implemented by the compiler for simple structs/classes. Then users could precisely control how their type can be destructured.

The optional "unapply" method is from the Scala language, and it's more or less what you are suggesting, with a different name (and I agree opSomething sounds like a more fitting name for D). Such opMatch has optional arguments too, because you can match in different ways.

Bye,
bearophile

Reply via email to