<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="">I did consider this but I think it would be too easy to accidentally upgrade an optional. When you may have been thinking you were dealing with an optional and you needed to chain them. <div class=""><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On Feb 4, 2016, at 7:45 AM, Jerome ALVES <<a href="mailto:j.alves@me.com" class="">j.alves@me.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=""><div class="">Maybe allowing optional chaining here is the best option ?</div><div class=""><br class=""></div><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(66, 66, 66);" class=""><div style="margin: 0px; line-height: normal; color: rgb(0, 118, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ff2f92" class="">let</span><span style="font-variant-ligatures: no-common-ligatures; color: #424242" class=""> test = </span><span style="font-variant-ligatures: no-common-ligatures; color: #d81e00" class="">"Test"</span><span style="font-variant-ligatures: no-common-ligatures; color: #424242" class=""> </span>// String</div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: #ff2f92" class="">let</span> testOrNil = <span style="font-variant-ligatures: no-common-ligatures; color: #d68945" class="">test</span>? <span style="font-variant-ligatures: no-common-ligatures; color: #007600" class="">// String?</span></div><div class=""><span style="font-variant-ligatures: no-common-ligatures; color: #007600" class=""><br class=""></span></div></div></div>- Jérôme<div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">Le 4 févr. 2016 à 16:32, Paul Ossenbruggen via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> a écrit :</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="">Just sugar for that, plus there is symmetry to this proposal, it is more discoverable, and it is more concise.<div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Feb 4, 2016, at 1:57 AM, Taras Zakharko <<a href="mailto:taras.zakharko@uzh.ch" class="">taras.zakharko@uzh.ch</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="">-1 from me<div class=""><br class=""></div><div class=""> let x = Optional(“Some Value”) </div><div class=""><br class=""></div><div class="">does the job just fine, is very clean, and I don’t see any reason to shorten it. </div><div class=""><br class=""></div><div class="">— Taras<br class=""><div class=""><br class=""></div><div class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On 04 Feb 2016, at 10:33, Allen Ding via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div dir="ltr" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">On Thu, Feb 4, 2016 at 4:28 PM, Paul Ossenbruggen via swift-evolution<span class="Apple-converted-space"> </span><span dir="ltr" class=""><<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>></span><span class="Apple-converted-space"> </span>wrote:<br class=""><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" 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 style="white-space: pre-wrap;" class="">        </span>let x = “Some Value”</div><div class=""><span style="white-space: pre-wrap;" class="">        </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></blockquote><div class=""><br class=""></div><div class="">Any use case examples? I've been trying to figure out why is this needs fixing (I don't even see it as a problem).</div><div class=""><br class=""></div><blockquote class="gmail_quote" style="margin: 0px 0px 0px 0.8ex; border-left-width: 1px; border-left-color: rgb(204, 204, 204); border-left-style: solid; padding-left: 1ex;"><div style="word-wrap: break-word;" class=""><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 style="white-space: pre-wrap;" class="">        </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<span class="Apple-converted-space"> </span><b class="">var</b><span class="Apple-converted-space"> </span>and<span class="Apple-converted-space"> </span><b class="">let</b><span class="Apple-converted-space"> </span>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><span class="Apple-converted-space"> </span>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 style="white-space: pre-wrap;" class="">        </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></div><br class="">_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""><br class=""></blockquote></div><br class=""></div></div><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">_______________________________________________</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><span style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px; float: none; display: inline !important;" class="">swift-evolution mailing list</span><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="mailto:swift-evolution@swift.org" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">swift-evolution@swift.org</a><br style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" style="font-family: Helvetica; font-size: 12px; font-style: normal; font-variant-caps: normal; font-weight: normal; letter-spacing: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px; -webkit-text-stroke-width: 0px;" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a></div></blockquote></div><br class=""></div></div></div></div></blockquote></div><br class=""></div></div>_______________________________________________<br class="">swift-evolution mailing list<br class=""><a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a><br class=""><a href="https://lists.swift.org/mailman/listinfo/swift-evolution" class="">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class=""></div></blockquote></div><br class=""></div></div></div></blockquote></div><br class=""></div></div></body></html>