October 26, 2021

On Tuesday, 26 October 2021 at 01:19:29 UTC, Andrei Alexandrescu wrote:

>

Versioning Phobos would free us from maintaining backward

can we improve this

if (isInputRange!(Range1) && isInputRange!(Range2))

to:

if isallInputRange(Range1,Range2)

?
C++'s concept is very grace.

October 26, 2021

On Tuesday, 26 October 2021 at 04:58:41 UTC, zjh wrote:

>

On Tuesday, 26 October 2021 at 01:19:29 UTC, Andrei

We can use a method similar to the C++ namespace without mixing the old code with the new code. Use an import std2 to open the std2 space. The new code is placed in the std2 directory. The new code copies all the old code first, and then modifies and tests on it.
The old std code remains as it is, and it is maintained and modified.
There is no need to mix the new code with the old code, otherwise, The function is too ugly.
However, we can say to the user that the maintenance period of the old std is "10 years / 5 years" ,then we will delete the old code and only maintain the "new code" as "std". If the user continues to use the "old code", it will be maintained by the user.
Preferably, you can also optimize the import, such as import std2: {algorithm, file, array} To batch import modules. with this simplifiction, users are naturally willing to migrate.

October 26, 2021

Or, if you don't want users to worry, you should use the following in the std Code:
Make the original std like version std = std1, and the current std like version std = std2.
I think we should do it at the std level, not at the function level, or we should do it one by one like fun!std, what a big hole.

October 25, 2021
On 10/25/21 9:58 PM, zjh wrote:
> On Tuesday, 26 October 2021 at 01:19:29 UTC, Andrei Alexandrescu wrote:
>> Versioning Phobos would free us from maintaining backward
> 
> can we improve this
> ```d
> if (isInputRange!(Range1) && isInputRange!(Range2))
> ```
> to:
> ```d
> if isallInputRange(Range1,Range2)
> ```
> ?
> `C++`'s `concept` is very grace.
> 
> 

Easy in D but the following otherwise-attractive-short-hand-method imports symbols at module level (at least privately):

private import std.meta : allSatisfy;
private import std.range : isInputRange;

alias isallInputRange(T...) = allSatisfy!(isInputRange, T);

void foo(A, B)(A a, B b)
if (isallInputRange!(A, B)) {
}

unittest {
  static assert ( __traits(compiles, foo([0], [0])));
  static assert (!__traits(compiles, foo([0], 42)));
  static assert (!__traits(compiles, foo(42, [0])));
}

void main() {
}

Ali
October 26, 2021
On Tuesday, 26 October 2021 at 01:19:29 UTC, Andrei Alexandrescu wrote:
> Goals of library versioning:
>
> - avoid copy-and-paste code duplication across versions
This might be overengineering.  Unless new features are going to be backported to the original std, is there anything wrong with just forking std to std2?
October 26, 2021
On Tuesday, 26 October 2021 at 01:19:29 UTC, Andrei Alexandrescu wrote:
>
> There are many other aspects to discuss, but I'll keep this short so the discussion doesn't meander too much.

The only problem I see when versioning the standard library is that some packages will rely on specific versions of the standard library and it could make it difficult to use packages that rely on different versions of the standard library.

In general I agree it would be a great idea, but we have to be careful about fragmenting things too much.
October 26, 2021
On Tuesday, 26 October 2021 at 01:19:29 UTC, Andrei Alexandrescu wrote:
> ...

I know this is basically a DOA suggestion, but what are your thoughts on embracing a package manager for the std?

For example, in C#-land any "additional" packages made by Microsoft are handled via the NuGet package manager, and are tagged in a way that aligns to the current version of .Net.

e.g. For .Net Core 3.1 the tag is v3.1.x, for 3.2 it's v3.2.x, etc.

https://www.nuget.org/packages/Microsoft.Extensions.Logging/

I'm not savvy enough to be able to state pros and cons though, so I leave that to others >;3
October 26, 2021

On Tuesday, 26 October 2021 at 05:59:44 UTC, Ali Çehreli wrote:

>

On 10/25/21 9:58 PM, zjh wrote:

Thank you for your reply:

void foo(A, B)(A a, B b)
if (isallInputRange!(A, B)) {
}

That's good. But I hope we can be better. Like this:

void foo(ConceptA A,ConceptB B)(A a, B b)
    if (ConceptAB!(A, B)) {
    ...
}

I hope that when conceptAB is not needed but conceptA/conceptB is needed, it will be added directly before A/B.
And the C++'s ... is very cool, but manu was defeated by Walter. Sometimes it's better to expand directly than to use array, Why doesn't Walter accept it?

October 26, 2021
On Tuesday, 26 October 2021 at 06:03:38 UTC, sarn wrote:
> On Tuesday, 26 October 2021 at 01:19:29 UTC, Andrei Alexandrescu wrote:
>> Goals of library versioning:
>>
>> - avoid copy-and-paste code duplication across versions
> This might be overengineering.  Unless new features are going to be backported to the original std, is there anything wrong with just forking std to std2?

Yeah, I kind of agree there, just copy the stuff. Simple and effective; no crazy mixins or module aliases.
October 26, 2021
On Tuesday, 26 October 2021 at 01:19:29 UTC, Andrei Alexandrescu wrote:
> [...]

Probably not the best idea but also this should work:

std.... >

version(NEW)
{
.....
}
else
{
....
}

std2...>

version = NEW