<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><div class=""><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="">If the URL path property was defined not to return ‘String?' but to return ‘Any’ (which can of course hold an Optional just like it can hold any other type) what would the proposed compiler behavior be?</div></div></div></blockquote><div class=""><br class=""></div><div class="">No warning. Since you cast Optional to Any, no warning can even be issued since that will eventually be determined during runtime, there's not much the compiler can do here.</div><div class=""><br class=""></div><div class="">Only if you returned `Any?` - which then Optional&lt;Any&gt;, anyway.</div><br class=""><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="">The actual definition of debugDescription is discouraged from being called by user code. This method also only coincidentally provides the identical text as string interpolation today. Are you proposing to change the standard library documentation to say that users should be calling debugDescription in this scenario, and change optional to define what its implementation of debugDescription returns?</div></div></div></blockquote><div class=""><br class=""></div><div class="">What about adding .description (i.e. comply to CustomStringConvertible) and calling .description instead? I'll update the proposal to match this.</div><br class=""><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="">If I have a type which I don’t want used in String interpolation, I would like to mark it as giving a warning. Examples would be a Result type for representing success or error from a function call, or a future type to represent a task dispatched to another thread that may or may not have finished and returned a result yet. Do you propose a way for me to have the compiler warn if I accidentally have these types used in string interpolation as well, or do I only benefit from optional as a special case.</div></div></div></blockquote><div class=""><br class=""></div><div class="">I'd prefer to leave the Optional as a special case handled by the language, but you can deprecate interpolation for custom types yourself - see below.</div><br class=""><blockquote type="cite" class=""><div class="" style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;"><div class=""><div class="">And finally, I can have my own type which implements StringInterpolationConvertible. Examples might be&nbsp;</div><div class="">- LocalizableString type which maps the provided string to correct user output through a localization table</div><div class="">- DebugString for debug logging that uses CustomDebugStringConvertible when available to represent types</div><div class="">- an HtmlEscapedString which deals with making values that don’t implement the HtmlEscaped protocol HTML-safe, including Strings</div><div class=""><br class=""></div><div class="">How would I get the optional usage defined for String type interpolation for these cases. DebugString would like to represent optionals as today, LocalizableString would like to capture optionals so that it can switch to a specific internationalized message in this case, and HtmlEscapedString would like the same behavior you are proposing for String.</div></div></div></blockquote><div class=""><br class=""></div><div class="">The deprecation doesn't necessarily need to be handled by the compiler itself, but can be enforced by the following code:</div><div class=""><br class=""></div><div class=""><div class="" style="margin: 0px; font-size: 9px; line-height: normal; font-family: Menlo; color: rgb(187, 44, 162);"><span class="" style="font-variant-ligatures: no-common-ligatures;">extension</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">String</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">&nbsp;{</span></div><div style="margin: 0px; font-size: 9px; line-height: normal; font-family: Menlo; min-height: 10px;" class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">        </span></span><br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 9px; line-height: normal; font-family: Menlo; color: rgb(209, 47, 27);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space: pre;">        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">@available</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">(*, deprecated, message=</span><span class="" style="font-variant-ligatures: no-common-ligatures;">"Interpolation of optionals is deprecated."</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);">)</span></div><div class="" style="margin: 0px; font-size: 9px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">        </span></span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);">init</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&lt;T&gt;(stringInterpolationSegment segment:&nbsp;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(112, 61, 170);">Optional</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&lt;</span><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);">T</span><span class="" style="font-variant-ligatures: no-common-ligatures;">&gt;) {</span></div><div class="" style="margin: 0px; font-size: 9px; line-height: normal; font-family: Menlo; color: rgb(0, 132, 0);"><span class="" style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 0, 0);"><span class="Apple-tab-span" style="white-space: pre;">                </span></span><span class="" style="font-variant-ligatures: no-common-ligatures;">// fatalError()</span></div><div class="" style="margin: 0px; font-size: 9px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">        </span>}</span></div><div style="margin: 0px; font-size: 9px; line-height: normal; font-family: Menlo; min-height: 10px;" class=""><span class="" style="font-variant-ligatures: no-common-ligatures;"><span class="Apple-tab-span" style="white-space: pre;">        </span></span><br class="webkit-block-placeholder"></div><div class="" style="margin: 0px; font-size: 9px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;">}</span></div><div class="" style="margin: 0px; font-size: 9px; line-height: normal; font-family: Menlo;"><span class="" style="font-variant-ligatures: no-common-ligatures;"><br class=""></span></div><div class="" style="margin: 0px; font-size: 9px; line-height: normal; font-family: Menlo;"><br class=""></div></div><div class="">With this kind of implementation, you get the warnings, however, without the compiler support you won't get the Fix-It for adding .description - I'm not sure the renamed= part of the attribute can be abused to do this, but I don't think it can be.</div><div class=""><br class=""></div><div class="">And in a similar fashion, you can deprecate the Optional or any other kind on your other strings and keep them on DebugString.</div><div class=""><br class=""></div><div class="">Charlie</div></div><div class=""><br class=""></div><blockquote type="cite" class=""><div class=""><div style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class=""><div class=""><div class="">-DW</div><div class=""><div class=""><br class=""></div></div></div></div></div></blockquote></div><br class=""></body></html>