Why does intpromote spew warnings for ~ operator?

jfondren julian.fondren at gmail.com
Tue Sep 14 07:29:39 UTC 2021


On Tuesday, 14 September 2021 at 07:01:02 UTC, Alexey wrote:
> On Tuesday, 14 September 2021 at 06:03:24 UTC, bauss wrote:
>>a lot of C code is/will be
>> ported to D
>
> mythical possibility

I did this just the other day, translating 500 lines of a C 
raylib implementation of Asteroids into D. Method: copy&paste and 
fix errors. The most annoying bit was the extensive use of C99 
struct initializers, a lot of

```c
player.collider = (Vector3){math, math, math};
```

into

```d
player.collider = Vector3(math, math, math);
```

The "if it compiles it's valid" is a very helpful rule for C code.

https://github.com/raysan5/raylib-games/blob/master/classics/src/asteroids.c
https://gist.github.com/jrfondren/7459713e2a4ad8d62d297abd4b0949d8

> all this doesn't answer why D should be like C

D being like D includes the idea that C code either compiles with 
the same meaning or it fails to compile. If not for that, why 
should D look C-like at all?

But putting C aside, is this even a behavior that you want?

```d
ushort x = 53;
int y = -x;
assert(y == 65483);
```

>. or is it like:
> * C++ is C with classes
> * D is C++ with GC
> , yes?
>
> so if C++ will gain GC - D will become unneeded?

C++ needs to lose a lot, not just gain.

For a fresh example, C++ needs to lose easily incoherent and 
tedious operator overloading: 
https://forum.dlang.org/post/mailman.283.1631549561.21945.digitalmars-d-learn@puremagic.com


More information about the Digitalmars-d mailing list