Editions Ideas
Richard (Rikki) Andrew Cattermole
richard at cattermole.co.nz
Tue Dec 23 00:40:57 UTC 2025
On 23/12/2025 1:29 PM, 6622 wrote:
> On Tuesday, 16 December 2025 at 21:08:39 UTC, Richard (Rikki) Andrew
> Cattermole wrote:
>> Yeah absolutely.
>>
>> But there will be some behavior that won't be replicated wrt.
>> overriding, and that is an intentional breakage.
>>
>> For instance I don't want fields supported, just a single method.
>> You don't need fields supported.
>>
>> ```d
>> T field;
>>
>> ref T opDispatch(string op : "") => field;
>> ```
>>
>> Longer sure, (and yes there are opinions about a different signature),
>> but it'll optimize out and keeps it being a simpler feature.
>>
>> I'm sure once discussed it'll change, I would be surprised if it
>> survives a meeting for what I came up with.
>
> I use alias this on my structs a lot.
>
> Its ideas like this that make me worry about editions regressing the
> language. Editions should be used for cleaning up the language, fixing
> up problematic semantics and ugly corners. This is very ugly and verbose
> compared to the current alias this syntax. Dont make D more C++ or Rust
> like :^)
It could yes, I am worried that if we keep the same syntax it'll cause
silent breakage.
As of right now, its more likely that we'll risk the breakage instead.
For the really interesting usage of alias this, you have a method
regardless, so if anything it shortens code down.
I'm expecting push back and then me dropping it.
> I support removing the multiple inheritance, it snuck into the language
> unintentionally. I also hope to see the graceful automatic type casting
> into the base type stay, its useful.
>
> If the syntax is to be changed, I liked the idea of it reusing the class
> inheretence syntax but for structs `struct Foo : BaseType {}`. Whatever
> the new syntax is, it needs to be good on the eyes! I have hundreds of
> simple structs that use alias this to create wrapper types, its useful
> for protecting from the wrong arguments being passed to functions & etc...
Struct inheritance is a separate feature.
Alias this is used for significantly more than just inheriting a struct
and if we only do one, it'll cause some code to not have a migration
path that needs this feature more.
More information about the Digitalmars-d
mailing list