Thoughts on versioning
Steven Schveighoffer
schveiguy at gmail.com
Thu Oct 28 14:30:38 UTC 2021
On 10/28/21 10:18 AM, Adam D Ruppe wrote:
> On Thursday, 28 October 2021 at 14:12:44 UTC, Steven Schveighoffer wrote:
>> is, if you pass a `std.stdio.File` to a function accepting a
>> `std2.stdio.File`, the compiler is given a way to convert the
>> internals/state.
>
> Well, if there was implicit construction, you could always make a
> constructor for the one File that accepts the other and converts.
This is going to still be a bit painful. I was thinking for more
compiler help.
For example, if you had:
```d
import lib1; // uses Phobos 1 File
import lib2; // uses Phobos 2 File
void foo()
{
lib2.funAcceptingFile(lib1.funProducingFile());
}
```
This is going to have an error, instead you need to do:
```d
void foo()
{
import std2.stdio : File;
lib2.funAcceptingFile(File(lib1.funProducingFile()));
}
```
Which isn't horrible, but could cause problems if you have both symbols.
I also imagine the error to be comical:
Error: No overload of funAcceptingFile accepts arguments (File).
Possible overloads:
void funAcceptingFile(File)
If the compiler just figured out the conversion is possible on the
original code (by being told how it can do that), then there's no need
to manually do this conversion.
> If you're willing to do a little work you can make it happen.
Sure, with a little work, you can make anything happen. But will people
be willing to do that work? If not, then won't we just end up with a lot
of effort to build and maintain something nobody uses? I personally
would rather just use the v2 exclusively, and eliminate any usage of v1.
-Steve
More information about the Digitalmars-d
mailing list