<div dir="ltr">On Mon, Dec 19, 2016 at 1:44 PM, David Sweeris via swift-evolution <span dir="ltr">&lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt;</span> wrote:<br><div class="gmail_extra"><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><span class=""><br><div><blockquote type="cite"><div>On Dec 19, 2016, at 11:36 AM, David Sweeris via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-8872252158133612552Apple-interchange-newline"><div><div style="word-wrap:break-word"><br><div><blockquote type="cite"><div>On Dec 19, 2016, at 11:21 AM, Erica Sadun via swift-evolution &lt;<a href="mailto:swift-evolution@swift.org" target="_blank">swift-evolution@swift.org</a>&gt; wrote:</div><br class="m_-8872252158133612552Apple-interchange-newline"><div><div style="word-wrap:break-word"><div><span style="font-variant-ligatures:no-common-ligatures">```swift</span></div><div><span style="font-family:Menlo;font-size:18px;font-variant-ligatures:no-common-ligatures;color:rgb(186,45,162)">let</span><span style="font-family:Menlo;font-size:18px;font-variant-ligatures:no-common-ligatures"> x = #imageLiteral(resourceName:&quot;<wbr>nothere.jpg&quot;)</span></div><div><div style="margin:0px;font-size:18px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">print(x)</span></div></div><div style="margin:0px;font-size:18px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures">```</span></div><div style="margin:0px;font-size:18px;line-height:normal;font-family:Menlo"><span style="font-variant-ligatures:no-common-ligatures"><br></span></div><div>This compiles. It crashes at runtime. I don&#39;t see why URLs should be any different.</div><div><br></div><div>— E</div></div></div></blockquote><br></div><div>They shouldn’t be. The print function can already handle things that aren’t `CustomStringConvertible`:</div><blockquote style="margin:0 0 0 40px;border:none;padding:0px"><div><div style="margin:0px;line-height:normal;font-family:Menlo;color:rgb(112,61,170)"><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures;color:#bb2ca2">struct</span><span style="font-variant-ligatures:no-common-ligatures"> Foo {}</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures;color:#bb2ca2">let</span><span style="font-variant-ligatures:no-common-ligatures"> x = </span><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187">Foo</span><span style="font-variant-ligatures:no-common-ligatures">()</span></div><div style="margin:0px;line-height:normal"><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187">Foo</span><span style="font-variant-ligatures:no-common-ligatures">.</span><span style="font-variant-ligatures:no-common-ligatures;color:#bb2ca2">self</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#bb2ca2">is</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures">CustomStringConvertible</span><span style="font-variant-ligatures:no-common-ligatures"> </span><span style="font-variant-ligatures:no-common-ligatures;color:#008400">//says `false`</span></div><div style="margin:0px;line-height:normal;color:rgb(0,132,0)"><span style="font-variant-ligatures:no-common-ligatures;color:#3d1d81">print</span><span style="font-variant-ligatures:no-common-ligatures">(</span><span style="font-variant-ligatures:no-common-ligatures;color:#4f8187">x</span><span style="font-variant-ligatures:no-common-ligatures">) </span><span style="font-variant-ligatures:no-common-ligatures">//says `&quot;Foo()\n&quot;`</span></div></div></div></blockquote><div>so, IMHO, that’s a bug.</div></div></div></blockquote><br></div></span><div>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><br></div><div>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&#39;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><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word">- Dave Sweeris</div><br>______________________________<wbr>_________________<br>
swift-evolution mailing list<br>
<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a><br>
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" target="_blank">https://lists.swift.org/<wbr>mailman/listinfo/swift-<wbr>evolution</a><br>
<br></blockquote></div><br></div></div>