May 19, 2022

On Wednesday, 18 May 2022 at 17:35:14 UTC, Walter Bright wrote:

>

More thinking about this suggests that int+noreturn should be typed as noreturn.

How so? This makes sense to me:

int divide(int dividend, int divisor)
{
    return divisor == 0
        ? assert(false, "You shall not divide by zero")
        : dividend / divisor;
}
May 19, 2022

On Wednesday, 18 May 2022 at 22:00:26 UTC, Bastiaan Veelo wrote:

>

On Tuesday, 17 May 2022 at 21:05:08 UTC, deadalnix wrote:

>

I use sublime text, which has decent support for D. At least as long as you don't use throw expressions.

There is your problem. Sublime Text likes to be different.

I edited the Editors wiki accordingly.

— Bastiaan

May 19, 2022

On Wednesday, 18 May 2022 at 22:00:26 UTC, Bastiaan Veelo wrote:

>

On Tuesday, 17 May 2022 at 21:05:08 UTC, deadalnix wrote:

>

I use sublime text, which has decent support for D. At least as long as you don't use throw expressions.

There is your problem. Sublime Text likes to be different.

According to the devs, Sublime has its own regex engine optimised for speed, and uses custom grammars for syntax highlighting. Whenever D evolves, someone needs to patch their grammar up; and it’s not the Sublime devs. I did that when the new contract format went live. I told the devs that it would be better for D to have a syntax highlighter based on one of the maintained parsers, but they replied that that would likely never be supported. That’s when I stopped using Sublime for D.

I’m currently using Visual Studio Community (not “Code”) which uses dmd as a library for the parsing.

— Bastiaan

It's not a problem, it is how it's done. Pretty no tooling today that is geared toward text edition uses the language's reference parser, because they need something that recover gracefully on invalid syntax rather than giving you an error.

The parser you need for the compiler != the parser you need for you editor, code formater, etc...

Consider this, clang and clang-format use different parsers.

May 19, 2022

On Thursday, 19 May 2022 at 09:11:45 UTC, Vladimir Panteleev wrote:

>

On Wednesday, 18 May 2022 at 17:35:14 UTC, Walter Bright wrote:

>

More thinking about this suggests that int+noreturn should be typed as noreturn.

How so? This makes sense to me:

int divide(int dividend, int divisor)
{
    return divisor == 0
        ? assert(false, "You shall not divide by zero")
        : dividend / divisor;
}

?: is different from + because evaluation of a ?: expression does not require evaluation of all of its operands.

Evaluation of a + expression with a noreturn operand is guaranteed to evaluate the noreturn operand, and therefore is guaranteed not to terminate, so the + expression itself can be typed as noreturn.

May 19, 2022

On Thursday, 19 May 2022 at 14:16:21 UTC, Paul Backus wrote:

>

?: is different from + because evaluation of a ?: expression does not require evaluation of all of its operands.

Evaluation of a + expression with a noreturn operand is guaranteed to evaluate the noreturn operand, and therefore is guaranteed not to terminate, so the + expression itself can be typed as noreturn.

Ah, so Walter meant addition literally. That does make sense. Thanks!

May 19, 2022

On Thursday, 19 May 2022 at 09:11:45 UTC, Vladimir Panteleev wrote:
[...]

>

How so? This makes sense to me:

int divide(int dividend, int divisor)
{
    return divisor == 0
        ? assert(false, "You shall not divide by zero")
        : dividend / divisor;
}

The condition should read

   divisor == 0 || dividend == int.min && divisor == -1

but that is not the reason why I am posting:

Issue 23126 - wrong result of integer division in presence of assert within conditional operator expression
https://issues.dlang.org/show_bug.cgi?id=23126

May 19, 2022

On Thursday, 19 May 2022 at 14:13:13 UTC, deadalnix wrote:

>

On Wednesday, 18 May 2022 at 22:00:26 UTC, Bastiaan Veelo wrote:

>

On Tuesday, 17 May 2022 at 21:05:08 UTC, deadalnix wrote:

>

I use sublime text, which has decent support for D. At least as long as you don't use throw expressions.

There is your problem. Sublime Text likes to be different.

According to the devs, Sublime has its own regex engine optimised for speed, and uses custom grammars for syntax highlighting. Whenever D evolves, someone needs to patch their grammar up;

[…]

>

It's not a problem, it is how it's done.

:-) What are you complaining about then? The problem is that Sublime Text will never be using any of the officially maintained parsers.

>

The parser you need for the compiler != the parser you need for you editor, code formater, etc...

Enter dparse.

— Bastiaan.

May 19, 2022

On Thursday, 19 May 2022 at 14:57:40 UTC, Bastiaan Veelo wrote:

>

:-) What are you complaining about then? The problem is that Sublime Text will never be using any of the officially maintained parsers.

Stop being s mart ass, thanks.

D has made 0 progress on tooling for 15 years. If you want to make sure this stay this way, keep on with this attitude, it's working great.

But keep in mind one thing, the tooling for the alternative was trash 15 years ago. Now it is rather good. And this is quickly making D an unattractive option.

May 22, 2022

I actually wanted, and forgot, to file a bug that you can no longer override a method with one marked with nothrow.

Since it only adds restrictions and is compatible with a method that throws, I think it is a good choice to support like contraverience or whichever it is.

Hmm I wonder if that works with const.

May 24, 2022

On Sunday, 22 May 2022 at 13:56:54 UTC, Jesse Phillips wrote:

>

I actually wanted, and forgot, to file a bug that you can no longer override a method with one marked with nothrow.

Since it only adds restrictions and is compatible with a method that throws, I think it is a good choice to support like contraverience or whichever it is.

Hmm I wonder if that works with const.

Do you have an example program that demonstrates this bug? The following program works for me when compiled with DMD 2.100.0:

class C
{
    void fun() { throw new Exception("oops"); }
}

class D : C
{
    override void fun() nothrow { }
}

void main()
{
    D d = new D;
    C c = new D;
    d.fun(); // ok
    c.fun(); // ok
}
1 2 3
Next ›   Last »