4 days ago

On Saturday, 2 November 2024 at 18:01:45 UTC, IchorDev wrote:

>

Nope, not even close. That medal has to go to integer promotion.

That seems off-topic for this DIP thread.

>
short x = 127;
short y = x / 2 + 1; //Error: integer promotion screwed you over again!

Actually that example compiles fine due to VRP.
https://dlang.org/spec/type.html#vrp

3 days ago

On Friday, 1 November 2024 at 12:26:25 UTC, ryuukk_ wrote:

>
enum State
{
    IDLE,
    RUN,
    ATTACK,
}


fn void main()
{
    State state = IDLE;
    if (state == RUN) {
        // run
    }
}

D needs to to better

You want that magic in C and more. But D is a much more stable language

#include <assert.h>

typedef enum {
  One, Two, Three, Four
} Numbers;

typedef struct {
    size_t counter;
} S;


int main()
{
  assert(Four == 3);
  auto arr[] = { One, Two, Three, Four };

  int Four = 43;
  S myStruct = {
    counter : Four
  };
  assert(myStruct.counter == 43);
}

SDB@79

1 2 3
Next ›   Last »