Most basic nothrow, pure, @safe functions?
Steven Schveighoffer
schveiguy at yahoo.com
Thu Mar 20 18:40:16 PDT 2014
On Thu, 20 Mar 2014 17:32:01 -0400, Walter Bright
<newshound2 at digitalmars.com> wrote:
> On 3/18/2014 5:49 PM, Walter Bright wrote:
>> On 3/18/2014 4:56 PM, Steven Schveighoffer wrote:
>>> Can we mark _d_monitorenter and _d_monitorexit nothrow and have the
>>> compiler see
>>> that when using synchronized? This was the hurdle we couldn't overcome
>>> in the
>>> referenced pull request.
>>>
>>> Should those be marked nothrow? What about pure and @safe?
>>
>> Good question. I don't have an answer at the moment.
>>
>
> I'm pretty sure they can't be pure. After all, monitors affect global
> state, can result in deadlocks, etc.
How do they affect global state?
Resulting in deadlocks does not make them impure. This is also a pure
function:
pure int foo()
{
while(1) {}
return 0;
}
Pure doesn't mean "bug free".
-Steve
More information about the Digitalmars-d
mailing list