On 15 November 2012 04:30, Andrei Alexandrescu <span dir="ltr"><<a href="mailto:SeeWebsiteForEmail@erdani.org" target="_blank">SeeWebsiteForEmail@erdani.org</a>></span> wrote:<br><div class="gmail_extra"><div class="gmail_quote">
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div class="im">On 11/11/12 6:30 PM, Walter Bright wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
1. ensure single threaded access by aquiring a mutex<br>
2. cast away shared<br>
3. operate on the data<br>
4. cast back to shared<br>
5. release the mutex<br>
</blockquote>
<br></div>
This is very different from how I view we should do things (and how we actually agreed to do things and how I wrote in TDPL).<br>
<br>
I can't believe I need to restart this on a cold cache.</blockquote><div><br></div><div>The pattern Walter describes is primitive and useful, I'd like to see shared assist to that end (see my previous post).</div>
<div>You can endeavour to do any other fancy stuff you like, but until some distant future when it's actually done, then proven and well supported, I'll keep doing this.</div><div><br></div><div>Not to repeat my prev post... but in reply to Walter's take on it, it would be interesting if 'shared' just added implicit lock()/unlock() methods to do the mutex acquisition and then remove the cast requirement, but have the language runtime assert that the object is locked whenever it is accessed (this guarantees the safety in a more useful way, the casts are really annying). I can't imagine a simpler and more immediately useful solution.</div>
<div><br></div><div>In fact, it's a reasonably small step to this being possible with user-defined attributes. Although attributes have no current mechanism to add a mutex, and lock/unlock methods to the object being attributed (like is possible in Java/C#), but maybe it's not a huge leap.</div>
</div></div>