Vision for the D language - stabilizing complexity?

Timon Gehr via Digitalmars-d digitalmars-d at puremagic.com
Fri Aug 5 21:19:28 PDT 2016


On 15.07.2016 22:29, Walter Bright wrote:
> 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.

Just to be explicit about this: What kind of "help" do you want to be 
provided to the optimizer?
I.e., why didn't you say: "Failing assertions are undefined behavior 
with the -release switch."


More information about the Digitalmars-d mailing list