<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8"></head><body dir="auto"><div></div><div>True, but it's not at all about brevity, it's about type-safety and getting compile-time checking rather than runtime checking of the validity of the URL structure.</div><div><br>On Dec 16, 2016, at 5:50 PM, Derrick Ho <<a href="mailto:wh1pch81n@gmail.com">wh1pch81n@gmail.com</a>> wrote:<br><br></div><blockquote type="cite"><div>let url = URL(string: "<a href="https://example.com">https://example.com</a>")!<br><br>let url = #url("<a href="https://example.com">https://example.com</a>")<br><br>Are not that different in length. It really isn't saving you much.<br><br>I suppose you can try overloading an operator to get something to the effect you want.<br><div class="gmail_quote"><div dir="ltr">On Fri, Dec 16, 2016 at 6:19 PM Micah Hainline via swift-evolution <<a href="mailto:swift-evolution@swift.org">swift-evolution@swift.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Exactly! It's not an earth-shattering pain, but it would be nice to have clean type safety there.<br class="gmail_msg">
<br class="gmail_msg">
> On Dec 16, 2016, at 4:01 PM, Charlie Monroe <<a href="mailto:charlie@charliemonroe.net" class="gmail_msg" target="_blank">charlie@charliemonroe.net</a>> wrote:<br class="gmail_msg">
><br class="gmail_msg">
><br class="gmail_msg">
>>> On Dec 16, 2016, at 10:05 PM, Charles Srstka via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>> wrote:<br class="gmail_msg">
>>><br class="gmail_msg">
>>> On Dec 16, 2016, at 2:46 PM, Micah Hainline via swift-evolution <<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a>> wrote:<br class="gmail_msg">
>>><br class="gmail_msg">
>>> I would like to be able to create a URL literal that is compile-time<br class="gmail_msg">
>>> checked for correct format. This would help avoid code like this:<br class="gmail_msg">
>>><br class="gmail_msg">
>>> let url: URL = URL(string: "<a href="https://example.com" rel="noreferrer" class="gmail_msg" target="_blank">https://example.com</a>")!<br class="gmail_msg">
>>><br class="gmail_msg">
>>> The cleanest way I can think of doing that would be to introduce a new<br class="gmail_msg">
>>> macro structure similar to #selector, though I'm open to other ideas.<br class="gmail_msg">
>>> I would think it should take a quoted literal string to avoid<br class="gmail_msg">
>>> problems. That would look like this:<br class="gmail_msg">
>>><br class="gmail_msg">
>>> let url: URL = #url("<a href="https://example.com" rel="noreferrer" class="gmail_msg" target="_blank">https://example.com</a>")<br class="gmail_msg">
>>><br class="gmail_msg">
>>> What does everyone think of that idea?<br class="gmail_msg">
>>> _______________________________________________<br class="gmail_msg">
>>> swift-evolution mailing list<br class="gmail_msg">
>>> <a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
>>> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
>><br class="gmail_msg">
>><br class="gmail_msg">
>> I’d like to see something like that for file path URLs. For something so commonly used, URL(fileURLWithPath:) is obnoxiously verbose.<br class="gmail_msg">
>><br class="gmail_msg">
>> Charles<br class="gmail_msg">
><br class="gmail_msg">
> Yes, but it's not a nullable initializer. With URL(string:) the incredible pain is that even compile-time URLs to your own website are nullable URL? and you need to force-unwrap them.<br class="gmail_msg">
><br class="gmail_msg">
>><br class="gmail_msg">
>> _______________________________________________<br class="gmail_msg">
>> swift-evolution mailing list<br class="gmail_msg">
>> <a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
>> <a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
><br class="gmail_msg">
_______________________________________________<br class="gmail_msg">
swift-evolution mailing list<br class="gmail_msg">
<a href="mailto:swift-evolution@swift.org" class="gmail_msg" target="_blank">swift-evolution@swift.org</a><br class="gmail_msg">
<a href="https://lists.swift.org/mailman/listinfo/swift-evolution" rel="noreferrer" class="gmail_msg" target="_blank">https://lists.swift.org/mailman/listinfo/swift-evolution</a><br class="gmail_msg">
</blockquote></div>
</div></blockquote></body></html>