July 27

On Wednesday, 27 July 2022 at 03:42:07 UTC, Walter Bright wrote:

>

On 7/26/2022 3:52 AM, Andrey Zherikov wrote:

>

But how should I check that a specific feature is added to compiler/phobos or a specific bug is fixed?

Create a single "configuration module", which has a section for each version:

module config;

version (DigitalMars)
{
    import digitalmars;
}
else version (LDC)
{
    import ldc;
}
else version (GDC)
{
    import gdc;
}
else
{
    static assert(0, "unsupported system");
}

Now, in digitalmars.d and ldc.d and gdc.d, do what it takes to make that configuration work for your code.

This makes it really easy to concentrate, say, in ldc.d, just on ldc's characteristics. Rather than having to constantly confuse yourself with which configuration is compiling what code.

What's your recommendation about how I should check for a specific feature/bugfix? Should I use static if(__VERSION__ ...), static if(__traits(compiles, { ... })) or something else?

July 27
On 7/27/2022 7:24 AM, Andrey Zherikov wrote:
> What's your recommendation about how I should check for a specific feature/bugfix? Should I use `static if(__VERSION__ ...)`, `static if(__traits(compiles, { ... }))` or something else?

__VERSION__ is certainly more convenient.

Though, since upgrades to the compiler are free, a simpler strategy would be to just require a __VERSION__ past a certain point.

July 28

On Wednesday, 27 July 2022 at 17:16:30 UTC, Walter Bright wrote:

>

On 7/27/2022 7:24 AM, Andrey Zherikov wrote:

>

What's your recommendation about how I should check for a specific feature/bugfix? Should I use static if(__VERSION__ ...), static if(__traits(compiles, { ... })) or something else?

VERSION is certainly more convenient.

Though, since upgrades to the compiler are free, a simpler strategy would be to just require a VERSION past a certain point.

Did I get you right that you discourage using static if for versioning the code (according to this post) with an exception for static if(__VERSION__ ...)?

July 28
On 7/28/2022 7:57 AM, Andrey Zherikov wrote:
> Did I get you right that you discourage using `static if` for versioning the code (according to [this post](https://forum.dlang.org/post/tbair7$2ltc$1@digitalmars.com)) with an exception for `static if(__VERSION__ ...)`?

Yes, you did.

Mainly, because the compiler doesn't generate a predefined version for every change, which is impractical.

Frankly, what you're trying to do is hopeless, hence the suggestion to simply pick a minimum __VERSION__ to support.

July 29
On Friday, 29 July 2022 at 01:04:42 UTC, Walter Bright wrote:
> On 7/28/2022 7:57 AM, Andrey Zherikov wrote:
>> Did I get you right that you discourage using `static if` for versioning the code (according to [this post](https://forum.dlang.org/post/tbair7$2ltc$1@digitalmars.com)) with an exception for `static if(__VERSION__ ...)`?
>
> Yes, you did.
>
> Mainly, because the compiler doesn't generate a predefined version for every change, which is impractical.
>
> Frankly, what you're trying to do is hopeless, hence the suggestion to simply pick a minimum __VERSION__ to support.

I'm just trying to clarify your recommendations as a language author. Whether I like it or not is different question but making things clear is important IMO. Thanks for your answers!
1 2 3 4 5 6 7
Next ›   Last »