Struct inheritance

Nick Treleaven nick at geany.org
Fri Sep 20 15:23:25 UTC 2024


On Thursday, 19 September 2024 at 19:04:40 UTC, Richard (Rikki) 
Andrew Cattermole wrote:
> On 20/09/2024 6:57 AM, Nick Treleaven wrote:
>> This seems like |alias this| in disguise.
>
> The problem with alias this, is it is not defined as the 
> fallback when nothing else in the hierarchy matches.
>
> Here it is better defined, opDispatch should only be chosen 
> after exhausting the hierarchy, both in classes and structs.

I don't see why you want to overload opDispatch to do subtyping. 
It doesn't seem related to existing opDispatch.

> Eliminating the issues with alias this from the design.
>
> We can further restrict it, to only support the parent most 
> type in the hierarchy or only one in the hierarchy. In effect 
> it allows adding a new parent to the top of the hierarchy.

I don't think we need to restrict its capabilities, we just need 
another syntax for it so we can fix the semantics. If anything 
I'd like to increase its capabilities. It could be defined as a 
template method and instantiated with the type of the expected 
result, and the constraint determines whether the conversion is 
enabled for that type. In effect, allowing multiple `alias this` 
with the semantics defined by the aggregate author.


More information about the dip.ideas mailing list