Vision for the D language - stabilizing complexity?
Walter Bright via Digitalmars-d
digitalmars-d at puremagic.com
Fri Jul 15 13:29:10 PDT 2016
On 7/15/2016 12:55 PM, Jack Stouffer wrote:
> On Friday, 15 July 2016 at 19:06:15 UTC, Walter Bright wrote:
>> 4. making use of asserts to provide information to the optimizer
>
> Do dmd/ldc/gdc actually do this?
dmd doesn't. I don't know about other compilers.
The point is it's possible because C++ doesn't have asserts. C++ has an assert
macro, defined to be the same as in C. The definition of assert in C is such
that it is turned on/off with the NDEBUG macro, meaning that when it is off, the
compiler CANNOT derive any semantic information from it, because it effectively
vanishes from the code.
In contrast, assert in D is a keyword and has a semantic production. Even if
generating code for the assert is disabled with the -release switch, the
semantics of it remain and are available to the optimizer.
C++ didn't repeat that mistake with 'static_assert' (another feature copied from
D), but static assert doesn't help the optimizer.
More information about the Digitalmars-d
mailing list