Something like ADL from C++?

Derek Fawcus dfawcus+dlang at employees.org
Tue Dec 3 18:22:16 UTC 2024


On Tuesday, 3 December 2024 at 17:35:36 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
> This won't help you today but:
>
> 1. We are considering giving structs inheritance as part of 
> replacing alias this.
>
> 2. I want a way to mark a method as 'reinterpreted' by the 
> child class/struct. Specifically for serialization, removing 
> the need for doing any lookups like this.

Please no.  Than then also makes the betterC subset too complex.

What facility of 'alias this' is it intended to preserve?  If 
only the implicit conversion, then a new form of operator, or 
special named member function strikes me as more suitable.

 From my perspective, one the the nice things about the class / 
strict difference is that struct does not have any classful 
behaviour, i.e. it has no inheritance.  If you add inheritance, 
that adds a thinking burden when reading code, and essentially 
removes the difference between class and struct, other than the 
implicit lock within classes.  I view the 'reference type' thing 
as a rather trivial difference.

One could add something like the struct embedding of 
Go/Limbo/Alef/Ken-C together with its implicit conversion for 
methods/functions.  The method is then interpreted by the 
embedded element, but against the embedded element, not the 
parent one.



More information about the Digitalmars-d mailing list