First Draft: Callback For Matching Type

Richard (Rikki) Andrew Cattermole richard at cattermole.co.nz
Mon Jun 24 18:42:21 UTC 2024


On 25/06/2024 6:20 AM, Quirin Schroll wrote:
> I guess I have implemented something like that: 
> https://d.godbolt.org/z/ePv4ndxeE
> 
> If I understand you correctly, we share the vision of a tagged union (I 
> call them enum unions) as a type with certain members (duck typing), not 
> the instance of a particular template.
> 
> But that’s where it seems our views diverge. In my implementation, the 
> tag also allows distinct same-type options. (Options are discerned by 
> tag, not by type.)

I'm for this, however since I don't have member-of-operator I can't 
really do this in the way that I'd like.

```d
expr.match {
	(:NameForTag var) => writeln(var);
}
```

Best to leave such support for future, unless a good proposal is given.



More information about the dip.development mailing list