<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=""><div class=""><b class="">Draft Proposal feedback welcome.</b></div><div class=""><b class=""><br class=""></b></div><div class=""><b class="">## Introduction</b></div><div class=""><br class=""></div>Currently to make a optional from a value the type name must be repeated:<div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>let x = “Some Value”</div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>let y : String? = x</div><div class=""><br class=""></div><div class="">This takes away some of the advantage of type inference because the very next line I must specify the type.</div><div class=""><br class=""></div><div class=""><b class="">## Proposal</b></div><div class=""><br class=""></div><div class="">I propose the following syntax:</div><div class=""><br class=""></div><div class=""><span class="Apple-tab-span" style="white-space:pre">        </span>let y? = x</div><div class=""><br class=""></div><div class="">This binds a new optional y which wraps the same value of x. It follows the same conventions as <b class="">var</b> and <b class="">let</b> that currently exist in the language. </div><div class=""><br class=""></div><div class=""><div class="">The advantages: this is easier to read, more compact, and lets type inference determine the type. </div></div><div class=""><br class=""></div><div class=""><b class="">If let</b> and other conditionals would not support this syntax and optionals of optionals is not supported. So let x?? = y would not result in an optional optional. Also if y was an optional it would not let you upgrade that.</div><div class=""><br class=""></div><div class=""><b class="">## Detailed Design</b></div><div class=""><br class=""></div><div class="">The grammar: </div><div class=""><br class=""></div><div class=""><div class=""><span class="Apple-tab-span" style="white-space: pre;">        </span>let optionalValue? = value</div></div><div class=""><br class=""></div><div class=""><div class="">This would not make sense in the <b class="">if let, (guard</b><b class=""> let)</b><b class=""> </b>context because <b class="">if let</b> unwraps the value, so this would be an error. </div></div><div class=""><br class=""></div><div class=""><div class="">This should not conflict with pattern matching as that requires the <b class="">case</b> keyword. </div></div><div class=""><br class=""></div><div class=""><div class="">Wrapping optional in an optional is an error. </div></div><div class=""><br class=""></div><div class=""><b class="">## Impact on existing code</b></div><div class=""><br class=""></div><div class="">The current syntax will continue to exist so it will have no impact on existing code. </div><div class=""><br class=""></div><div class=""><b class="">## Alternatives Considered</b></div><div class=""><br class=""></div><div class="">None. </div><div class=""><br class=""></div><div class=""><br class=""></div></body></html>