<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Jan 18, 2016, at 7:57 PM, <a href="mailto:davesweeris@mac.com" class="">davesweeris@mac.com</a> wrote:</div><br class="Apple-interchange-newline"><div class=""><meta http-equiv="Content-Type" content="text/html charset=utf-8" class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">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 class="">and</i> is declared with the lazy behavior?<div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);" class=""><span style="color: rgb(79, 129, 135);" class="">x</span><span style="" class="">.</span><span style="color: rgb(79, 129, 135);" class="">lazy</span><span style="" class="">.</span><span style="color: rgb(49, 89, 93);" class="">clear</span><span style="" class="">() </span>// a property named “lazy” which has a clear() method</div><div style="margin: 0px; line-height: normal;" class=""><span style="font-family: Menlo; font-size: 11px; color: rgb(79, 129, 135);" class="">x</span><font face="Menlo" class=""><span style="font-size: 11px;" class="">#lazy.clear() </span></font><font color="#008400" face="Menlo" class=""><span style="font-size: 11px;" class="">// the behavior named “lazy”</span></font></div></div><div class="">I kinda like “#” (or whatever) for declaring them, too:</div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color: rgb(187, 44, 162);" class="">var</span> x #(<span style="color: rgb(79, 129, 135);" class="">lazy</span>) = <span style="color: rgb(39, 42, 216);" class="">6</span></div></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><br class=""></div></div><div class=""><br class=""></div><div class=""><br class=""></div><div class=""><div class="">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 class=""><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="color: rgb(187, 44, 162);" class="">struct</span> Lazy<T> {</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""> <span style="color: rgb(187, 44, 162);" class="">private</span> <span style="color: rgb(187, 44, 162);" class="">let</span> closure: () -> <span style="color: rgb(112, 61, 170);" class="">T</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""> <span style="color: rgb(187, 44, 162);" class="">private</span> <span style="color: rgb(187, 44, 162);" class="">var</span> storage: <span style="color: rgb(112, 61, 170);" class="">T</span>? = <span style="color: rgb(187, 44, 162);" class="">nil</span></div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""> <span style="color: rgb(187, 44, 162);" class="">var</span> value: <span style="color: rgb(112, 61, 170);" class="">T</span> {</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span><span style="color: rgb(187, 44, 162);" class="">mutating</span> <span style="color: rgb(187, 44, 162);" class="">get</span> {</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span> <span style="color: rgb(187, 44, 162);" class="">if</span> <span style="color: rgb(79, 129, 135);" class="">storage</span> == <span style="color: rgb(187, 44, 162);" class="">nil</span> { <span style="color: rgb(79, 129, 135);" class="">storage</span> = <span style="color: rgb(79, 129, 135);" class="">closure</span>() }</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""> <span style="color: rgb(187, 44, 162);" class="">return</span> <span style="color: rgb(79, 129, 135);" class="">storage</span>!</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>}</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span style="color: rgb(187, 44, 162);" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>mutating</span> <span style="color: rgb(187, 44, 162);" class="">set</span> {</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span> <span style="color: rgb(79, 129, 135);" class="">storage</span> = newValue</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>}</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""> }</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""> <span style="color: rgb(187, 44, 162);" class="">init</span>(<span style="color: rgb(187, 44, 162);" class="">_</span> closure: () -> <span style="color: rgb(112, 61, 170);" class="">T</span>) {</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""> <span style="color: rgb(187, 44, 162);" class="">self</span>.<span style="color: rgb(79, 129, 135);" class="">closure</span> = closure</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class=""> }</div><div style="font-family: Menlo; font-size: 11px; margin: 0px; line-height: normal;" class="">}</div></div><div class=""><br class=""></div><div class="">then the only difference between</div></div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">lazy</span> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> foo = {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""> <span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">return</span> <span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">4</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div></div><div style="margin: 0px; line-height: normal;" class="">and</div><div style="margin: 0px; line-height: normal;" class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> foo = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">Lazy</span> {</div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);" class=""><span style="" class=""> </span>return<span style="" class=""> </span><span style="font-variant-ligatures: no-common-ligatures; color: #272ad8" class="">4</span></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class="">}</div><div class="">is that in the former case, the property is implicitly accessed:</div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> bar = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">foo</span></div></div><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color: rgb(79, 129, 135);" class="">foo</span> = <span style="color: rgb(39, 42, 216);" class="">10</span></div></div><div class="">and in the latter, we have to access it explicitly:</div><div class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #bb2ca2" class="">var</span> bar = <span style="font-variant-ligatures: no-common-ligatures; color: #4f8187" class="">foo</span>.<span style="font-variant-ligatures: no-common-ligatures; color: #31595d" class="">value</span></div></div><div class=""><div style="margin: 0px; line-height: normal;" class=""><div style="margin: 0px; font-size: 11px; line-height: normal; font-family: Menlo;" class=""><span style="color: rgb(79, 129, 135);" class="">foo</span>.<span style="color: rgb(49, 89, 93);" class="">value</span> = <span style="color: rgb(39, 42, 216);" class="">10</span></div><div class=""><br class=""></div><div class="">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);" class="">struct</span><span style="font-family: Menlo; font-size: 11px;" class=""> Lazy<T> {</span><br class=""><span style="font-size: 11px; color: rgb(0, 132, 0); font-family: Menlo;" class=""> // or whatever the magic syntax is</span><br class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> </span></font><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">mutating static</span><font face="Menlo" class=""><span style="font-size: 11px;" class=""> </span></font><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">get</span><font face="Menlo" class=""><span style="font-size: 11px;" class=""> { () -> T </span></font><span style="color: rgb(187, 44, 162); font-family: Menlo; font-size: 11px;" class="">in</span><font face="Menlo" class=""><span style="font-size: 11px;" class=""> </span></font><span style="color: rgb(0, 132, 0); font-family: Menlo; font-size: 11px;" class="">// $0 is an instance of </span><font color="#008400" face="Menlo" class=""><span style="font-size: 11px;" class="">Lazy<T></span></font><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""><span class="Apple-tab-span" style="white-space:pre">        </span>if $0.</span><span style="color: rgb(79, 129, 135); font-family: Menlo; font-size: 11px;" class="">value</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px;" class="">==</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">nil</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px;" class="">{ </span><span style="font-family: Menlo; font-size: 11px;" class="">$0.</span><span style="color: rgb(79, 129, 135); font-family: Menlo; font-size: 11px;" class="">value</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px;" class="">=</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px;" class="">$0.</span><span style="font-family: Menlo; font-size: 11px; color: rgb(79, 129, 135);" class="">closure</span><span style="font-family: Menlo; font-size: 11px;" class="">() }</span><br class=""><span class="Apple-tab-span" style="font-family: Menlo; font-size: 11px; white-space: pre;">        </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">return</span><span style="font-family: Menlo; font-size: 11px;" class=""> $0.</span><span style="font-family: Menlo; font-size: 11px; color: rgb(79, 129, 135);" class="">value</span><span style="font-family: Menlo; font-size: 11px;" class="">!</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""> }</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">mutating</span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">static</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">set</span><span style="font-family: Menlo; font-size: 11px;" class=""> { (newValue:T) </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">in</span><span style="font-family: Menlo; font-size: 11px;" class=""> $0.</span><span style="font-family: Menlo; font-size: 11px; color: rgb(79, 129, 135);" class="">value</span><span style="font-family: Menlo; font-size: 11px;" class=""> = newValue</span><span style="font-family: Menlo; font-size: 11px;" class=""> }</span><br class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""><br class=""></span></font><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">private</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">let</span><span style="font-family: Menlo; font-size: 11px;" class=""> closure: () -> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(112, 61, 170);" class="">T</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">private</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">var</span><span style="font-family: Menlo; font-size: 11px;" class=""> value: </span><span style="font-family: Menlo; font-size: 11px; color: rgb(112, 61, 170);" class="">T</span><span style="font-family: Menlo; font-size: 11px;" class="">? = </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">nil</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">init</span><span style="font-family: Menlo; font-size: 11px;" class="">(</span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">_</span><span style="font-family: Menlo; font-size: 11px;" class=""> closure: () -> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(112, 61, 170);" class="">T</span><span style="font-family: Menlo; font-size: 11px;" class="">) {</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">self</span><span style="font-family: Menlo; font-size: 11px;" class="">.</span><span style="font-family: Menlo; font-size: 11px; color: rgb(79, 129, 135);" class="">value</span><span style="font-family: Menlo; font-size: 11px;" class=""> = closure</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px;" class="">}</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class="">}</span><br class=""><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">enum</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px;" class="">Optional<T> {</span><br class=""><font face="Menlo" style="font-family: Menlo;" class=""><span style="font-size: 11px;" class=""> </span></font><span style="font-family: Menlo; font-size: 11px; color: rgb(0, 132, 0);" class="">// no need for a custom getter, since you have to manually unwrap optionals</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">mutating</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">static</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">set</span><span style="font-family: Menlo; font-size: 11px;" class=""> { (newValue: T) </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">in</span><span style="font-family: Menlo; font-size: 11px;" class=""> $0 = .Some(newValue) } </span><span style="font-family: Menlo; font-size: 11px; color: rgb(0, 132, 0);" class="">// $0 is an instance of </span><font color="#008400" face="Menlo" style="font-family: Menlo; font-size: 11px;" class="">Optional<T></font><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">mutating</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">static</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">set</span><span style="font-family: Menlo; font-size: 11px;" class=""> { () </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">in</span><span style="font-family: Menlo; font-size: 11px;" class=""> $0</span><span style="font-family: Menlo; font-size: 11px;" class=""> = .None }</span><br class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""><br class=""></span></font><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">case</span><span style="font-family: Menlo; font-size: 11px;" class=""> None</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">case</span><span style="font-family: Menlo; font-size: 11px;" class=""> Some(T)</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">init</span><span style="font-family: Menlo; font-size: 11px;" class="">() { </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">self</span><span style="font-family: Menlo; font-size: 11px;" class=""> = .</span><span style="font-family: Menlo; font-size: 11px; color: rgb(49, 89, 93);" class="">None</span><span style="font-family: Menlo; font-size: 11px;" class=""> }</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">init</span><span style="font-family: Menlo; font-size: 11px;" class="">(nilLiteral: ()) { </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">self</span><span style="font-family: Menlo; font-size: 11px;" class=""> = .</span><span style="font-family: Menlo; font-size: 11px; color: rgb(49, 89, 93);" class="">None</span><span style="font-family: Menlo; font-size: 11px;" class=""> }</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">init</span><span style="font-family: Menlo; font-size: 11px;" class="">(</span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">_</span><span style="font-family: Menlo; font-size: 11px;" class=""> value: </span><span style="font-family: Menlo; font-size: 11px; color: rgb(112, 61, 170);" class="">T</span><span style="font-family: Menlo; font-size: 11px;" class="">) { </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">self</span><span style="font-family: Menlo; font-size: 11px;" class=""> = .</span><span style="font-family: Menlo; font-size: 11px; color: rgb(49, 89, 93);" class="">Some</span><span style="font-family: Menlo; font-size: 11px;" class="">(value) }</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class="">}</span><br class=""><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">enum</span><span style="font-family: Menlo; font-size: 11px;" class=""> ImplicitlyUnwrappedOptional<T> {</span><br class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""> </span></font><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">mutating</span><font face="Menlo" class=""><span style="font-size: 11px;" class=""> </span></font><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">static</span><font face="Menlo" class=""><span style="font-size: 11px;" class=""> </span></font><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">get</span><font face="Menlo" class=""><span style="font-size: 11px;" class=""> { () -> T </span></font><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">in </span><span style="font-family: Menlo; font-size: 11px; color: rgb(0, 132, 0);" class="">// $0 is an instance of ImplicitlyUnwrapped</span><font color="#008400" face="Menlo" class=""><span style="font-size: 11px;" class="">Optional<T></span></font><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">switch</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px;" class="">$0</span><span style="font-family: Menlo; font-size: 11px;" class=""> {</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">case</span><span style="font-family: Menlo; font-size: 11px;" class=""> .None: </span><span style="font-family: Menlo; font-size: 11px; color: rgb(61, 29, 129);" class="">fatalError</span><span style="font-family: Menlo; font-size: 11px;" class="">(</span><span style="color: rgb(209, 47, 27); font-family: Menlo; font-size: 11px;" class="">"Error unwrapping ImplicitlyUnwrappedOptional"</span><span style="font-family: Menlo; font-size: 11px;" class="">)</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">case</span><span style="font-family: Menlo; font-size: 11px;" class=""> .Some(</span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">let</span><span style="font-family: Menlo; font-size: 11px;" class=""> value): </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">return</span><span style="font-family: Menlo; font-size: 11px;" class=""> value</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px;" class="">}</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""> }</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">mutating</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">static</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">set</span><span style="font-family: Menlo; font-size: 11px;" class=""> { (newValue: T) </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">in</span><span style="font-family: Menlo; font-size: 11px;" class=""> $0 = .Some(newValue) }</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">mutating</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">static</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">set</span><span style="font-family: Menlo; font-size: 11px;" class=""> { () </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">in</span><span style="font-family: Menlo; font-size: 11px;" class=""> $0 = .None }</span><br class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""><br class=""></span></font><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">case</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px;" class="">None</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">case</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px;" class="">Some(T)</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">init</span><span style="font-family: Menlo; font-size: 11px;" class="">() {</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">self</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px;" class="">= .</span><span style="font-family: Menlo; font-size: 11px; color: rgb(49, 89, 93);" class="">None</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px;" class="">}</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">init</span><span style="font-family: Menlo; font-size: 11px;" class="">(nilLiteral: ()) {</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">self</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px;" class="">= .</span><span style="font-family: Menlo; font-size: 11px; color: rgb(49, 89, 93);" class="">None</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px;" class="">}</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">init</span><span style="font-family: Menlo; font-size: 11px;" class="">(</span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">_</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px;" class="">value:</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(112, 61, 170);" class="">T</span><span style="font-family: Menlo; font-size: 11px;" class="">) {</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px; color: rgb(187, 44, 162);" class="">self</span><span style="font-family: Menlo; font-size: 11px;" class=""> </span><span style="font-family: Menlo; font-size: 11px;" class="">= .</span><span style="font-family: Menlo; font-size: 11px; color: rgb(49, 89, 93);" class="">Some</span><span style="font-family: Menlo; font-size: 11px;" class="">(value) }</span><br class=""><span style="font-family: Menlo; font-size: 11px;" class="">}</span><br class=""><font face="Menlo" class=""><span style="font-size: 11px;" class=""><br class=""></span></font><div style="margin: 0px; line-height: normal;" class=""><div class="">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 class="">and</i> it’d let us implement our own type-related custom behaviors. It’s a win-win!</div></div></div></div></blockquote><br class=""></div><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><br class=""></div><div>-Joe</div><br class=""></body></html>