Small @nogc experience report

Atila Neves atila.neves at gmail.com
Thu Sep 20 10:50:49 UTC 2018


On Thursday, 20 September 2018 at 03:01:02 UTC, Shachar Shemesh 
wrote:
> On 19/09/18 22:53, Walter Bright wrote:
>> On 9/19/2018 10:13 AM, Shachar Shemesh wrote:
>>>    assert(condition, string); // string is useless without 
>>> actual info about what went wrong.
>>>    assert(condition, format(string, arg, arg)); // No good - 
>>> format is not @nogc
>> 
>> Another method:
>> 
>>    debug
>>      assert(condition, format(string, arg, arg));
>>    else
>>      assert(condition, string);
>> 
>> because @nogc is ignored in debug conditionals, just like 
>> purity is ignored in debug conditionals.
>
> That doesn't cut it on so many levels...
>
> First of all, no four lines solution that requires copy/paste 
> (or worse, retyping) as a standard will actually get employed 
> by programmers. The disincentive is too high.

This pattern is incredibly easy to wrap and reuse as needed. I 
would've done already if only I'd known @nogc was ignored as well 
as pure.



More information about the Digitalmars-d mailing list