Opportunities for D

bearophile via Digitalmars-d digitalmars-d at puremagic.com
Wed Jul 9 02:07:36 PDT 2014


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


More information about the Digitalmars-d mailing list