Why does intpromote spew warnings for ~ operator?
Mike Parker
aldacron at gmail.com
Tue Sep 14 09:04:02 UTC 2021
On Tuesday, 14 September 2021 at 08:42:20 UTC, Alexey wrote:
>
> C can do also many other bad things silently - so what, should
> D support such behavior too? maybe D should silently support
> pointer magic, so C coder could easily copy-paste he's code to
> D?
Obviously not. That's why there are C constructs that do not
compile in D.
From the inception of D, a general rule has been that if C code
is copied into a D source module _and it compiles_, then it
should behave like C. This isn't about being "backward
compatible" with C. It's about minimizing bugs in ported code.
For example, when you're using a C library and you copy an
example into your D code, if it compiles and then behaves
differently, you've potentially introduced a silent bug.
In the early days, D programs were highly dependent on C
libraries because D libraries didn't exist. So this loose rule
that Walter tried to follow made a lot of sense. Today, we have
more D libraries, but we still frequently make use of C
libraries. The rule still makes sense, IMO.
More information about the Digitalmars-d
mailing list