Concept proposal: Safely catching error

Steven Schveighoffer via Digitalmars-d digitalmars-d at puremagic.com
Thu Jun 8 07:13:53 PDT 2017


On 6/8/17 9:42 AM, Olivier FAURE wrote:
> On Thursday, 8 June 2017 at 12:20:19 UTC, Steven Schveighoffer wrote:
>> Hm... if you locked an object that was passed in on the stack, for
>> instance, there is no guarantee the object gets unlocked.
>>
>
> This wouldn't be allowed unless the object was duplicated / created
> inside the try block.

void foo(Mutex m, Data d) pure
{
    synchronized(m)
    {
    	// ... manipulate d
    } // no guarantee m gets unlocked
}

-Steve


More information about the Digitalmars-d mailing list