<div dir="ltr">I'm surprised no one has said this yet, but nice work Joe for getting a partial implementation we can start to play with! :)<div><br></div><div>I'm sure it will help to better understand the impact of the proposal and how it relates to our code in a more concrete/practical way.</div><div><br></div><div><span class="im"><li style="margin-left:15px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'"><b>What is your evaluation of the proposal?</b></li></span><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol">+1</font></font><span class="im"><li style="margin-left:15px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'"><b>Is the problem being addressed significant enough to warrant a change to Swift?</b></li></span><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol">Yes, I'm excited by the potential here, and once the idea has had some real-world use I would like to see this pattern applied to more things.<br></font><span class="im"><li style="margin-left:15px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'"><b>Does this proposal fit well with the feel and direction of Swift?</b></li></span><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol">Yes.</font></font><span class="im"><li style="margin-left:15px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'"><b>If you have used other languages or libraries with a similar feature, how do you feel that this proposal compares to those?</b></li></span><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol">C# and Java have some annotation systems, they are loosely related. I've used them and found they add a lot of power to those languages, I've not tried to implement them though so I cannot comment on that.<br></font><span class="im"><li style="margin-left:15px;color:rgb(51,51,51);font-family:'Helvetica Neue',Helvetica,'Segoe UI',Arial,freesans,sans-serif,'Apple Color Emoji','Segoe UI Emoji','Segoe UI Symbol'"><b>How much effort did you put into your review? A glance, a quick reading, or an in-depth study?</b></li></span><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol">Only a brief look unfortunately, I've been skimming the new posts, but other than reading the proposal I haven't had time to look more thoroughly.</font><br></div><div><font color="#333333" face="Helvetica Neue, Helvetica, Segoe UI, Arial, freesans, sans-serif, Apple Color Emoji, Segoe UI Emoji, Segoe UI Symbol"><br></font></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Thu, Feb 18, 2016 at 4:18 AM, Joe Groff via swift-evolution <span dir="ltr"><<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">If anyone wants to start playing with the feature, I now have some of the core functionality working in a branch:<div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><a href="https://github.com/apple/swift/pull/1297" target="_blank">https://github.com/apple/swift/pull/1297</a></div></blockquote><div><br></div><div>I didn't want to waste time parsing a behavior declaration syntax while we're still painting the bikeshed, so behaviors are currently exposed as protocols with extension methods following a convention:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div>protocol delayedImmutable {</div></div><div> // Type of the property.</div><div><div> associatedtype Value</div></div><div> // Storage required by the property.</div><span class=""><div><div> var storage: Value? { get set }</div></div><div><div>}</div></div></span><div><div>extension delayedImmutable {</div></div><div> // Implementation of the property.</div><div><div> var value: Value {</div></div><div><div> // The property can only be read after it's been initialized.</div></div><div><div> get {</div></div><div><div> guard let theValue = storage else {</div></div><div><div> fatalError("delayedImmutable property read before initialization")</div></div><div><div> }</div></div><div><div> return theValue</div></div><div><div> }</div></div><div><div> </div></div><div><div> // The property can only be written once to initialize it.</div></div><div><div> set {</div></div><div><div> guard storage == nil else {</div></div><div><div> fatalError("delayedImmutable property rewritten after initialization")</div></div><div><div> }</div></div><div><div> storage = newValue</div></div><div><div> }</div></div><div><div> }</div></div><div><div><br></div></div><div> // Initialization logic for the property storage.</div><span class=""><div><div> static func initStorage() -> Value? {</div></div><div><div> return nil</div></div><div><div> }</div></div><div><div>}</div></div></span></blockquote><div><div><br></div></div><div>Custom accessors and initializer expression bindings aren't handled yet, but there's enough there now to implement `delayed` initialization. Here's an example test case:</div><div><br></div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><a href="https://github.com/jckarter/swift/commit/9da36f8e1e45564a61da4cfc9ed5327bf57862df" target="_blank">https://github.com/jckarter/swift/commit/9da36f8e1e45564a61da4cfc9ed5327bf57862df</a></div><div><br></div></blockquote>-Joe</div><br>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br>
<br></blockquote></div><br></div>