Most basic nothrow, pure, @safe functions?

Andrei Alexandrescu SeeWebsiteForEmail at erdani.org
Thu Mar 20 19:42:24 PDT 2014


On 3/20/14, 6:52 PM, Steven Schveighoffer wrote:
> On Thu, 20 Mar 2014 21:44:38 -0400, bearophile
> <bearophileHUGS at lycos.com> wrote:
>
>> Steven Schveighoffer:
>>
>>> This is also a pure function:
>>>
>>> pure int foo()
>>> {
>>>    while(1) {}
>>>    return 0;
>>> }
>>>
>>> Pure doesn't mean "bug free".
>>
>> Thankfully the D compiler catches the bug :-)
>>
>> test.d(3,4): Warning: statement is not reachable
>
> I can make it not catch that error, but that is not the bug. The bug is
> that it never returns, effectively deadlocking. The sample is
> intentionally short to demonstrate my point, I (obviously) didn't try to
> compile it.
>
> -Steve

My dream: pure @safe functions never cause deadlock.

Andrei



More information about the Digitalmars-d mailing list