[swift-evolution] URL Literals
Micah Hainline
micah.hainline at gmail.com
Fri Dec 16 18:17:24 CST 2016
I'm not sure I fully understand the value proposition of having all those different kinds of literals, but one piece of feedback I have on that is the previously established format for the # notation should be #camelCase rather than #dot.separated.
> On Dec 16, 2016, at 5:41 PM, Erica Sadun <erica at ericasadun.com> wrote:
>
> Take a peek at this: https://gist.github.com/erica/c92f6ab115af89d5c4b9161487df6a3c
>
> --E
>
>> On Dec 16, 2016, at 2:58 PM, Micah Hainline via swift-evolution <swift-evolution at swift.org> wrote:
>>
>> Charles,
>>
>> There's already something like that for file URLs in a playground,
>> though I'm not sure about compile-time checking or how that might work
>> outside of playgrounds.
>>
>> https://lists.swift.org/pipermail/swift-evolution-announce/2016-March/000060.html
>>
>> Of course, my proposal would work fine for file URLs, just not for
>> turning file paths INTO URLs.
>>
>> On Fri, Dec 16, 2016 at 3:05 PM, Charles Srstka
>> <cocoadev at charlessoft.com> wrote:
>>>> On Dec 16, 2016, at 2:46 PM, Micah Hainline via swift-evolution <swift-evolution at swift.org> wrote:
>>>>
>>>> I would like to be able to create a URL literal that is compile-time
>>>> checked for correct format. This would help avoid code like this:
>>>>
>>>> let url: URL = URL(string: "https://example.com")!
>>>>
>>>> The cleanest way I can think of doing that would be to introduce a new
>>>> macro structure similar to #selector, though I'm open to other ideas.
>>>> I would think it should take a quoted literal string to avoid
>>>> problems. That would look like this:
>>>>
>>>> let url: URL = #url("https://example.com")
>>>>
>>>> What does everyone think of that idea?
>>>> _______________________________________________
>>>> swift-evolution mailing list
>>>> swift-evolution at swift.org
>>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>>>
>>>
>>> I’d like to see something like that for file path URLs. For something so commonly used, URL(fileURLWithPath:) is obnoxiously verbose.
>>>
>>> Charles
>>>
>> _______________________________________________
>> swift-evolution mailing list
>> swift-evolution at swift.org
>> https://lists.swift.org/mailman/listinfo/swift-evolution
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.swift.org/pipermail/swift-evolution/attachments/20161216/a88c100e/attachment.html>
More information about the swift-evolution
mailing list