<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 Dec 19, 2016, at 11:48 AM, Xiaodi Wu <<a href="mailto:xiaodi.wu@gmail.com" class="">xiaodi.wu@gmail.com</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 Mon, Dec 19, 2016 at 1:44 PM, David Sweeris 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=""><span class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 19, 2016, at 11:36 AM, David Sweeris via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:</div><br class="m_-8872252158133612552Apple-interchange-newline"><div class=""><div style="word-wrap: break-word;" class=""><br class=""><div class=""><blockquote type="cite" class=""><div class="">On Dec 19, 2016, at 11:21 AM, Erica Sadun via swift-evolution <<a href="mailto:swift-evolution@swift.org" target="_blank" class="">swift-evolution@swift.org</a>> wrote:</div><br class="m_-8872252158133612552Apple-interchange-newline"><div class=""><div style="word-wrap: break-word;" class=""><div class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">```swift</span></div><div class=""><span style="font-family: Menlo; font-size: 18px; font-variant-ligatures: no-common-ligatures; color: rgb(186, 45, 162);" class="">let</span><span style="font-family: Menlo; font-size: 18px; font-variant-ligatures: no-common-ligatures;" class=""><span class="Apple-converted-space"> </span>x = #imageLiteral(resourceName:"<wbr class="">nothere.jpg")</span></div><div class=""><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">print(x)</span></div></div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class="">```</span></div><div style="margin: 0px; font-size: 18px; line-height: normal; font-family: Menlo;" class=""><span style="font-variant-ligatures: no-common-ligatures;" class=""><br class=""></span></div><div class="">This compiles. It crashes at runtime. I don't see why URLs should be any different.</div><div class=""><br class=""></div><div class="">— E</div></div></div></blockquote><br class=""></div><div class="">They shouldn’t be. The print function can already handle things that aren’t `CustomStringConvertible`:</div><blockquote style="margin: 0px 0px 0px 40px; border: none; padding: 0px;" class=""><div class=""><div style="margin: 0px; line-height: normal; font-family: Menlo; color: rgb(112, 61, 170);" class=""><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">struct</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="Apple-converted-space"> </span>Foo {}</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">let</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="Apple-converted-space"> </span>x =<span class="Apple-converted-space"> </span></span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">Foo</span><span style="font-variant-ligatures: no-common-ligatures;" class="">()</span></div><div style="margin: 0px; line-height: normal;" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">Foo</span><span style="font-variant-ligatures: no-common-ligatures;" class="">.</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">self</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="Apple-converted-space"> </span></span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(187, 44, 162);" class="">is</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="Apple-converted-space"> </span></span><span style="font-variant-ligatures: no-common-ligatures;" class="">CustomStringConvertible</span><span style="font-variant-ligatures: no-common-ligatures;" class=""><span class="Apple-converted-space"> </span></span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(0, 132, 0);" class="">//says `false`</span></div><div style="margin: 0px; line-height: normal; color: rgb(0, 132, 0);" class=""><span style="font-variant-ligatures: no-common-ligatures; color: rgb(61, 29, 129);" class="">print</span><span style="font-variant-ligatures: no-common-ligatures;" class="">(</span><span style="font-variant-ligatures: no-common-ligatures; color: rgb(79, 129, 135);" class="">x</span><span style="font-variant-ligatures: no-common-ligatures;" class="">)<span class="Apple-converted-space"> </span></span><span style="font-variant-ligatures: no-common-ligatures;" class="">//says `"Foo()\n"`</span></div></div></div></blockquote><div class="">so, IMHO, that’s a bug.</div></div></div></blockquote><br class=""></div></span><div class="">Oh, hey, wait a second… I didn’t catch the meaning of the resource name, and thought you meant it was crashing on the print statement. I still think it’s a bug, because the compiler should be able to check if the resource exists.</div></div></blockquote><div class=""><br class=""></div><div class="">I think the point here is that what exists at compile time may not exist at runtime and vice versa, so while a warning might be elegant, it's not helpful for the compiler to refuse to proceed on the basis that the image does not yet exist. At the end of the day, an image literal hardcodes the path to an image, not the image itself. Whether it ought to is another kettle of fish.</div></div></div></div></div></blockquote><br class=""></div><div>Ah, ok, I didn’t realize that image literals weren’t actually created until runtime... In that case, I retract my statement that they shouldn't be any different, because they while they both may be called “literals", they use that word to mean to two quite different things.</div><div><br class=""></div><div>- Dave Sweeris</div><br class=""></body></html>