<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="">-1 from me<div class=""><br class=""></div><div class="">&nbsp; let x = Optional(“Some Value”)&nbsp;</div><div class=""><br class=""></div><div class="">does the job just fine, is very clean, &nbsp;and I don’t see any reason to shorten it.&nbsp;</div><div class=""><br class=""></div><div class="">— Taras<br class=""><div class=""><br class=""></div><div class=""><br class=""><div><blockquote type="cite" class=""><div class="">On 04 Feb 2016, at 10:33, Allen Ding via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" class="">swift-evolution@swift.org</a>&gt; 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">&nbsp;</span><span dir="ltr" class="">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>&gt;</span><span class="Apple-converted-space">&nbsp;</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">&nbsp;</span><b class="">var</b><span class="Apple-converted-space">&nbsp;</span>and<span class="Apple-converted-space">&nbsp;</span><b class="">let</b><span class="Apple-converted-space">&nbsp;</span>that currently exist in the language.&nbsp;</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.&nbsp;</div></div><div class=""><br class=""></div><div class=""><b class="">If let</b><span class="Apple-converted-space">&nbsp;</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:&nbsp;</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&nbsp;<b class="">if let, (guard</b><b class="">&nbsp;let)</b><b class="">&nbsp;</b>context because&nbsp;<b class="">if let</b>&nbsp;unwraps the value, so this would be an error.&nbsp;</div></div><div class=""><br class=""></div><div class=""><div class="">This should not conflict with pattern matching as that requires the&nbsp;<b class="">case</b>&nbsp;keyword.&nbsp;</div></div><div class=""><br class=""></div><div class=""><div class="">Wrapping optional in an optional is an error.&nbsp;</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.&nbsp;</div><div class=""><br class=""></div><div class=""><b class="">## Alternatives Considered</b></div><div class=""><br class=""></div><div class="">None.&nbsp;</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></body></html>