<div dir="ltr"><div>And how about:</div><div><br></div><div>instead that:</div><div><pre style="overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;padding:16px;border-radius:3px;word-wrap:normal;word-break:normal;background-color:rgb(247,247,247)"><span style="color:rgb(51,51,51)"><span class="pl-k" style="color:rgb(167,29,93)">var</span> behavior Foo: <span class="pl-c1" style="color:rgb(0,134,179)">Int</span> {
</span><font color="#a71d5d">// behavior body</font><font color="#333333">
}</font></pre></div><div>that:</div><div><pre style="overflow:auto;font-family:Consolas,'Liberation Mono',Menlo,Courier,monospace;font-size:13.6px;margin-top:0px;margin-bottom:0px;font-stretch:normal;line-height:1.45;padding:16px;border-radius:3px;word-wrap:normal;word-break:normal;background-color:rgb(247,247,247)"><span style="color:rgb(51,51,51)"><span class="pl-k" style="color:rgb(167,29,93)">struct</span> Foo<</span><span style="color:rgb(0,134,179);font-size:13.6px;line-height:1.45">Int</span><span style="font-size:13.6px;line-height:1.45;color:rgb(51,51,51)">>: </span><span style="font-size:13.6px;line-height:1.45;color:rgb(167,29,93)">behavior</span><span style="font-size:13.6px;line-height:1.45;color:rgb(51,51,51)">{</span><br><span style="color:rgb(51,51,51)"> </span><font color="#a71d5d">// behavior body</font><font color="#333333">
}</font></pre></div><div><br></div><div><br></div><div>Or something like that....</div></div><br><div class="gmail_quote"><div dir="ltr">Em ter, 19 de jan de 2016 às 02:03, Joe Groff via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> escreveu:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On Jan 18, 2016, at 7:57 PM, <a href="mailto:davesweeris@mac.com" target="_blank">davesweeris@mac.com</a> wrote:</div><br><div><div style="word-wrap:break-word">Can we use “#” or something other than “.”, both to make it clear we’re referencing a behavior rather than a property, and so that we can avoid naming collisions when x has a property “lazy” <i>and</i> is declared with the lazy behavior?<div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(0,132,0)"><span style="color:rgb(79,129,135)">x</span><span>.</span><span style="color:rgb(79,129,135)">lazy</span><span>.</span><span style="color:rgb(49,89,93)">clear</span><span>() </span>// a property named “lazy” which has a clear() method</div><div style="margin:0px;line-height:normal"><span style="font-family:Menlo;font-size:11px;color:rgb(79,129,135)">x</span><font face="Menlo"><span style="font-size:11px">#lazy.clear() </span></font><font color="#008400" face="Menlo"><span style="font-size:11px">// the behavior named “lazy”</span></font></div></div><div>I kinda like “#” (or whatever) for declaring them, too:</div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(187,44,162)">var</span> x #(<span style="color:rgb(79,129,135)">lazy</span>) = <span style="color:rgb(39,42,216)">6</span></div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><br></div></div><div><br></div><div><br></div><div><div>I’m a definite +1 on the concepts behind your proposal, but there are really two distinct things going on here: behaviors that mess with the type, and those that don’t. I mean, if you define your Lazy “behavior” like this:</div><div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal"><span style="color:rgb(187,44,162)">struct</span> Lazy<T> {</div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal"> <span style="color:rgb(187,44,162)">private</span> <span style="color:rgb(187,44,162)">let</span> closure: () -> <span style="color:rgb(112,61,170)">T</span></div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal"> <span style="color:rgb(187,44,162)">private</span> <span style="color:rgb(187,44,162)">var</span> storage: <span style="color:rgb(112,61,170)">T</span>? = <span style="color:rgb(187,44,162)">nil</span></div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal"> <span style="color:rgb(187,44,162)">var</span> value: <span style="color:rgb(112,61,170)">T</span> {</div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal"><span style="white-space:pre-wrap">        </span><span style="color:rgb(187,44,162)">mutating</span> <span style="color:rgb(187,44,162)">get</span> {</div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal"><span style="white-space:pre-wrap">        </span> <span style="color:rgb(187,44,162)">if</span> <span style="color:rgb(79,129,135)">storage</span> == <span style="color:rgb(187,44,162)">nil</span> { <span style="color:rgb(79,129,135)">storage</span> = <span style="color:rgb(79,129,135)">closure</span>() }</div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal"> <span style="color:rgb(187,44,162)">return</span> <span style="color:rgb(79,129,135)">storage</span>!</div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal"><span style="white-space:pre-wrap">        </span>}</div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal"><span style="color:rgb(187,44,162)"><span style="white-space:pre-wrap">        </span>mutating</span> <span style="color:rgb(187,44,162)">set</span> {</div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal"><span style="white-space:pre-wrap">        </span> <span style="color:rgb(79,129,135)">storage</span> = newValue</div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal"><span style="white-space:pre-wrap">        </span>}</div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal"> }</div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal"> <span style="color:rgb(187,44,162)">init</span>(<span style="color:rgb(187,44,162)">_</span> closure: () -> <span style="color:rgb(112,61,170)">T</span>) {</div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal"> <span style="color:rgb(187,44,162)">self</span>.<span style="color:rgb(79,129,135)">closure</span> = closure</div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal"> }</div><div style="font-family:Menlo;font-size:11px;margin:0px;line-height:normal">}</div></div><div><br></div><div>then the only difference between</div></div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#bb2ca2">lazy</span> <span style="color:#bb2ca2">var</span> foo = {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"> <span style="color:#bb2ca2">return</span> <span style="color:#272ad8">4</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</div></div><div style="margin:0px;line-height:normal">and</div><div style="margin:0px;line-height:normal"><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#bb2ca2">var</span> foo = <span style="color:#4f8187">Lazy</span> {</div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo;color:rgb(187,44,162)"><span> </span>return<span> </span><span style="color:#272ad8">4</span></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo">}</div><div>is that in the former case, the property is implicitly accessed:</div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#bb2ca2">var</span> bar = <span style="color:#4f8187">foo</span></div></div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(79,129,135)">foo</span> = <span style="color:rgb(39,42,216)">10</span></div></div><div>and in the latter, we have to access it explicitly:</div><div><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:#bb2ca2">var</span> bar = <span style="color:#4f8187">foo</span>.<span style="color:#31595d">value</span></div></div><div><div style="margin:0px;line-height:normal"><div style="margin:0px;font-size:11px;line-height:normal;font-family:Menlo"><span style="color:rgb(79,129,135)">foo</span>.<span style="color:rgb(49,89,93)">value</span> = <span style="color:rgb(39,42,216)">10</span></div><div><br></div><div>If we expose the mechanism currently used by `T!` to convert between itself and T, and allow structs, enums, classes, and maybe even protocols to provide type accessors as well as property accessors, Lazy, Optional, and ImplicitlyUnwrappedOptional could then be implemented like this:</div></div></div><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">struct</span><span style="font-family:Menlo;font-size:11px"> Lazy<T> {</span><br><span style="font-size:11px;color:rgb(0,132,0);font-family:Menlo"> // or whatever the magic syntax is</span><br><font face="Menlo"><span style="font-size:11px"> </span></font><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">mutating static</span><font face="Menlo"><span style="font-size:11px"> </span></font><span style="color:rgb(187,44,162);font-family:Menlo;font-size:11px">get</span><font face="Menlo"><span style="font-size:11px"> { () -> T </span></font><span style="color:rgb(187,44,162);font-family:Menlo;font-size:11px">in</span><font face="Menlo"><span style="font-size:11px"> </span></font><span style="color:rgb(0,132,0);font-family:Menlo;font-size:11px">// $0 is an instance of </span><font color="#008400" face="Menlo"><span style="font-size:11px">Lazy<T></span></font><br><span style="font-family:Menlo;font-size:11px"><span style="white-space:pre-wrap">        </span>if $0.</span><span style="color:rgb(79,129,135);font-family:Menlo;font-size:11px">value</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px">==</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">nil</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px">{ </span><span style="font-family:Menlo;font-size:11px">$0.</span><span style="color:rgb(79,129,135);font-family:Menlo;font-size:11px">value</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px">=</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px">$0.</span><span style="font-family:Menlo;font-size:11px;color:rgb(79,129,135)">closure</span><span style="font-family:Menlo;font-size:11px">() }</span><br><span style="font-family:Menlo;font-size:11px;white-space:pre-wrap">        </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">return</span><span style="font-family:Menlo;font-size:11px"> $0.</span><span style="font-family:Menlo;font-size:11px;color:rgb(79,129,135)">value</span><span style="font-family:Menlo;font-size:11px">!</span><br><span style="font-family:Menlo;font-size:11px"> }</span><br><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">mutating</span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">static</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">set</span><span style="font-family:Menlo;font-size:11px"> { (newValue:T) </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">in</span><span style="font-family:Menlo;font-size:11px"> $0.</span><span style="font-family:Menlo;font-size:11px;color:rgb(79,129,135)">value</span><span style="font-family:Menlo;font-size:11px"> = newValue</span><span style="font-family:Menlo;font-size:11px"> }</span><br><font face="Menlo"><span style="font-size:11px"><br></span></font><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">private</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">let</span><span style="font-family:Menlo;font-size:11px"> closure: () -> </span><span style="font-family:Menlo;font-size:11px;color:rgb(112,61,170)">T</span><br><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">private</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">var</span><span style="font-family:Menlo;font-size:11px"> value: </span><span style="font-family:Menlo;font-size:11px;color:rgb(112,61,170)">T</span><span style="font-family:Menlo;font-size:11px">? = </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">nil</span><br><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">init</span><span style="font-family:Menlo;font-size:11px">(</span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">_</span><span style="font-family:Menlo;font-size:11px"> closure: () -> </span><span style="font-family:Menlo;font-size:11px;color:rgb(112,61,170)">T</span><span style="font-family:Menlo;font-size:11px">) {</span><br><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">self</span><span style="font-family:Menlo;font-size:11px">.</span><span style="font-family:Menlo;font-size:11px;color:rgb(79,129,135)">value</span><span style="font-family:Menlo;font-size:11px"> = closure</span><br><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px">}</span><br><span style="font-family:Menlo;font-size:11px">}</span><br><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">enum</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px">Optional<T> {</span><br><font face="Menlo" style="font-family:Menlo"><span style="font-size:11px"> </span></font><span style="font-family:Menlo;font-size:11px;color:rgb(0,132,0)">// no need for a custom getter, since you have to manually unwrap optionals</span><br><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">mutating</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">static</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">set</span><span style="font-family:Menlo;font-size:11px"> { (newValue: T) </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">in</span><span style="font-family:Menlo;font-size:11px"> $0 = .Some(newValue) } </span><span style="font-family:Menlo;font-size:11px;color:rgb(0,132,0)">// $0 is an instance of </span><font color="#008400" face="Menlo" style="font-family:Menlo;font-size:11px">Optional<T></font><br><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">mutating</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">static</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">set</span><span style="font-family:Menlo;font-size:11px"> { () </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">in</span><span style="font-family:Menlo;font-size:11px"> $0</span><span style="font-family:Menlo;font-size:11px"> = .None }</span><br><font face="Menlo"><span style="font-size:11px"><br></span></font><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">case</span><span style="font-family:Menlo;font-size:11px"> None</span><br><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">case</span><span style="font-family:Menlo;font-size:11px"> Some(T)</span><br><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">init</span><span style="font-family:Menlo;font-size:11px">() { </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">self</span><span style="font-family:Menlo;font-size:11px"> = .</span><span style="font-family:Menlo;font-size:11px;color:rgb(49,89,93)">None</span><span style="font-family:Menlo;font-size:11px"> }</span><br><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">init</span><span style="font-family:Menlo;font-size:11px">(nilLiteral: ()) { </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">self</span><span style="font-family:Menlo;font-size:11px"> = .</span><span style="font-family:Menlo;font-size:11px;color:rgb(49,89,93)">None</span><span style="font-family:Menlo;font-size:11px"> }</span><br><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">init</span><span style="font-family:Menlo;font-size:11px">(</span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">_</span><span style="font-family:Menlo;font-size:11px"> value: </span><span style="font-family:Menlo;font-size:11px;color:rgb(112,61,170)">T</span><span style="font-family:Menlo;font-size:11px">) { </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">self</span><span style="font-family:Menlo;font-size:11px"> = .</span><span style="font-family:Menlo;font-size:11px;color:rgb(49,89,93)">Some</span><span style="font-family:Menlo;font-size:11px">(value) }</span><br><span style="font-family:Menlo;font-size:11px">}</span><br><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">enum</span><span style="font-family:Menlo;font-size:11px"> ImplicitlyUnwrappedOptional<T> {</span><br><font face="Menlo"><span style="font-size:11px"> </span></font><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">mutating</span><font face="Menlo"><span style="font-size:11px"> </span></font><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">static</span><font face="Menlo"><span style="font-size:11px"> </span></font><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">get</span><font face="Menlo"><span style="font-size:11px"> { () -> T </span></font><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">in </span><span style="font-family:Menlo;font-size:11px;color:rgb(0,132,0)">// $0 is an instance of ImplicitlyUnwrapped</span><font color="#008400" face="Menlo"><span style="font-size:11px">Optional<T></span></font><br><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">switch</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px">$0</span><span style="font-family:Menlo;font-size:11px"> {</span><br><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">case</span><span style="font-family:Menlo;font-size:11px"> .None: </span><span style="font-family:Menlo;font-size:11px;color:rgb(61,29,129)">fatalError</span><span style="font-family:Menlo;font-size:11px">(</span><span style="color:rgb(209,47,27);font-family:Menlo;font-size:11px">"Error unwrapping ImplicitlyUnwrappedOptional"</span><span style="font-family:Menlo;font-size:11px">)</span><br><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">case</span><span style="font-family:Menlo;font-size:11px"> .Some(</span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">let</span><span style="font-family:Menlo;font-size:11px"> value): </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">return</span><span style="font-family:Menlo;font-size:11px"> value</span><br><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px">}</span><br><span style="font-family:Menlo;font-size:11px"> }</span><br><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">mutating</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">static</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">set</span><span style="font-family:Menlo;font-size:11px"> { (newValue: T) </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">in</span><span style="font-family:Menlo;font-size:11px"> $0 = .Some(newValue) }</span><br><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">mutating</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">static</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">set</span><span style="font-family:Menlo;font-size:11px"> { () </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">in</span><span style="font-family:Menlo;font-size:11px"> $0 = .None }</span><br><font face="Menlo"><span style="font-size:11px"><br></span></font><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">case</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px">None</span><br><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">case</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px">Some(T)</span><br><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">init</span><span style="font-family:Menlo;font-size:11px">() {</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">self</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px">= .</span><span style="font-family:Menlo;font-size:11px;color:rgb(49,89,93)">None</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px">}</span><br><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">init</span><span style="font-family:Menlo;font-size:11px">(nilLiteral: ()) {</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">self</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px">= .</span><span style="font-family:Menlo;font-size:11px;color:rgb(49,89,93)">None</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px">}</span><br><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">init</span><span style="font-family:Menlo;font-size:11px">(</span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">_</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px">value:</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(112,61,170)">T</span><span style="font-family:Menlo;font-size:11px">) {</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px;color:rgb(187,44,162)">self</span><span style="font-family:Menlo;font-size:11px"> </span><span style="font-family:Menlo;font-size:11px">= .</span><span style="font-family:Menlo;font-size:11px;color:rgb(49,89,93)">Some</span><span style="font-family:Menlo;font-size:11px">(value) }</span><br><span style="font-family:Menlo;font-size:11px">}</span><br><font face="Menlo"><span style="font-size:11px"><br></span></font><div style="margin:0px;line-height:normal"><div>One of the stated goals of Swift 3 is to move stuff out of the core language and into the standard library, right? Well, this would get rid of all the “magic” behind Lazy, Optionals, and ImplicitlyUnwrappedOptionals <i>and</i> it’d let us implement our own type-related custom behaviors. It’s a win-win!</div></div></div></div></blockquote><br></div></div><div style="word-wrap:break-word"><div>Getting rid of magic is definitely a goal, but I think we want to go in the *opposite* direction. Implicit Optional promotion creates lots of problems, and ImplicitlyUnwrappedOptional's behavior can be hard to predict. We plan to reform the type system around both kinds of Optional soon. Behaviors also give us an opportunity to eliminate at least one case for IUO by modeling delayed initialization as a behavior. I'd prefer not to introduce more messy implicit promotions.</div></div><div style="word-wrap:break-word"><div><br></div><div>-Joe</div><br></div>_______________________________________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org" target="_blank">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>
</blockquote></div>