Great work Joe! I really like this.<div><br></div><div>I presume the standard library will come with the existing lazy behavior.<div><br></div><div>It would be nice to have access the sync function used by Swift 2 'lazy', but for new behaviors. It may be that the usefulness/consistency of this is contingent on lazy being implemented only with the standard library (maybe dispatch?)</div><div><br></div><div>My only concern is that it's not currently obvious (without the proposal) what the type requirements of a behavior are. It feels like it could have a protocol but probably doesn't need one as it's a language feature. <font size="2"><span style="-webkit-tap-highlight-color: rgba(26, 26, 26, 0.301961);">A badly conforming behavior would really need good</span></font> and accurate error messages.</div><div><br></div><div>It would be important that these are debugable, and that lldb prints something sensible when you print an instance using them.</div><div><br></div><div>I missed it if it was mentioned, but access to a behavior (i.e. <font size="2"><span style="background-color:rgba(255,255,255,0)">foo<span class="pl-k" style="box-sizing: border-box;">.</span>resettable<span class="pl-k" style="box-sizing: border-box;">.</span>reset()) should probably be private by default, and perhaps allow other access modifiers<span></span>.</span></font></div><div><br>On Friday, 18 December 2015, Michel Fortin via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Le 17 déc. 2015 à 16:36, Joe Groff <<a href="javascript:;" onclick="_e(event, 'cvml', 'jgroff@apple.com')">jgroff@apple.com</a>> a écrit :<br>
<br>
>> On Dec 17, 2015, at 1:14 PM, Michel Fortin <<a href="javascript:;" onclick="_e(event, 'cvml', 'michel.fortin@michelf.ca')">michel.fortin@michelf.ca</a>> wrote:<br>
>><br>
>> About synchronized access, it seems to me that it'd be advantageous if implementing subscript in a behaviour was optional. This way you can force access of a property through a synchronized block which will help avoid races:<br>
>><br>
>> var (synchronized) data: (x: Int, y: Int, z: Int)<br>
>><br>
>> func test() {<br>
>> data.synchronize { (data) in<br>
>> data.x += 1<br>
>> data.y += data.x<br>
>> data.z += data.y<br>
>> }<br>
>> }<br>
><br>
> Interesting. IIUC, if a behavior didn't supply a subscript operation, then the property could *only* be accessed through its behavior interface?<br>
<br>
Exactly. It's much better than having a `fatalError("Don't access directly")` in the subscript getter.<br>
<br>
--<br>
Michel Fortin<br>
<a href="javascript:;" onclick="_e(event, 'cvml', 'michel.fortin@michelf.ca')">michel.fortin@michelf.ca</a><br>
<a href="https://michelf.ca" target="_blank">https://michelf.ca</a><br>
<br>
_______________________________________________<br>
swift-evolution mailing list<br>
<a href="javascript:;" onclick="_e(event, 'cvml', 'swift-evolution@swift.org')">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
</blockquote></div></div>