Editions Ideas
Jonathan M Davis
newsgroup.d at jmdavisprog.com
Wed Dec 17 17:35:41 UTC 2025
On Tuesday, December 16, 2025 1:35:18 PM Mountain Standard Time Nick Treleaven via Digitalmars-d wrote:
> On Monday, 15 December 2025 at 16:59:07 UTC, Lance Bachmeier
> wrote:
> > On Monday, 15 December 2025 at 12:26:04 UTC, Nick Treleaven
> > wrote:
> >> For structs, I think there was some plan to replace it, but I
> >> never saw details.
> >
> > Walter has indicated a desire to not use editions as an excuse
> > to ruin the language.
> >
> > alias this with structs is very useful. There is no reason to
> > remove it or make it unusable just because a few people think
> > it can be dangerous. One might also argue that pointers are
> > dangerous, but that's not an argument for removing them.
> > Removal of alias this would make the language unusable for me.
>
> I don't know if there is a plan now to replace it, I'd guess not.
> I am not aware of any reason why `alias this` should be removed
> (for structs at least). If there was a replacement feature, it
> should be capable of everything `alias this` can currently do
> IMO, so that there would be an upgrade path.
>
> There was a project item to 'Explore a replacement for alias
> this':
> https://github.com/orgs/dlang/projects/22/views/1?pane=issue&itemId=29572699
>
> Though that was part of a set which was closed (maybe last year).
At dconf in 2024, it was discussed that we would ideally get rid of alias
this but that we weren't going to, because it would break existing code. As
a replacement, Walter's proposal was to add struct inheritance so that you'd
do something like
struct S : Base
{
}
and all of the members of Base would effectively be copy-pasted into S. That
way, a struct could inherit the members of another struct, but there would
be no implicit conversion that resulted, because S wouldn't be a Base (like
occurs with class inheritance). It would just be copying the implementation.
That way, it's possible to reuse code without having all of the problems
that the implicit conversion that alias this introduces causes.
However, AFAIK, Walter hasn't actually done anything with that idea yet, and
there isn't a DIP for it yet.
It's possible that once such struct inheritance is in the language that we'd
then get rid of alias this in a future Edition, but no such decision has
been made. And regardless of what happens with that in the future, I don't
think that there's any chance that alias this would be removed in the first
Edition. The struct inheritance stuff needs to be sorted out first.
- Jonathan M Davis
More information about the Digitalmars-d
mailing list