D Editions
Jonathan M Davis
newsgroup.d at jmdavisprog.com
Fri May 31 16:39:11 UTC 2024
On Friday, May 31, 2024 10:29:54 AM MDT Atila Neves via dip.ideas wrote:
> On Friday, 31 May 2024 at 00:56:36 UTC, Gregor Mückl wrote:
> > On Thursday, 30 May 2024 at 18:31:48 UTC, Atila Neves wrote:
> >> https://github.com/atilaneves/DIPs/blob/editions/editions.md
> >>
> >> Destroy!
> >
> > How are editions going to retain compatibility across modules
> > with different ABIs? I believe that combinations of inheritance
> > and interface implementations may make this quite challenging.
> >
> > A probably needlessly convoluted example would be this:
> >
> > - a module A, edition 2024, containing a class Foo
> > - a module B, edition 2024+x, containing a class Bar, and
> > - a module C, edition 2024+y, defining an interface IFooBar and
> > two classes FooBar_Foo and FooBar_Bar that derive from Foo and
> > Bar respectively, but implement the IFooBar interface on top of
> > them.
> >
> > Any function that takes a IFooBar should be able to take both
> > implementation interchangeably. But how would this work if
> > there was an ABI change to the class memory layout affecting
> > Foo and Bar?
>
> Interesting question! Given the interface ABI now
> (https://dlang.org/spec/abi.html#interfaces), if we don't change
> that all of this *should* work. But suppose a future edition
> changes the ABI for interfaces (unlikely). It would probably be
> complicated to implement in the compiler, but I can't see any
> fundamental problems there: we know what module the interface is
> defined in, so we know what layout to expect for any function
> taking one. If I'm wrong I'd love if someone educated me.
>
> It's much more likely we change the ABI for classes in a future
> edition though, or the root class.
One crucial element here is that the expectation is that all of the code
will be built with the same version of the same compiler. We're going for
source compatibility, not binary compatibility. So, as long as the compiler
is able to compile the code in a fashion that it all works correctly, we're
fine regardless of how previous versions of the compiler would have compiled
that code. And there is no guarantee of ABI compatibility across compiler
versions. So, unless there's something fundamental that changes with an
edition where we can't maintain compatibility, we're fine, and the previous
discussions on this came to the conclusion that if making a change in an
edition was going to make it so that you couldn't have multiple editions
interacting together, then we couldn't make that change.
- Jonathan M Davis
More information about the dip.ideas
mailing list