[swift-evolution] multi-line string literals.
Vladimir.S
svabox at gmail.com
Mon May 9 02:23:57 CDT 2016
Btw, in c# we have @ to drop escapes:
@"c:\Docs\Source\a.txt" // rather than "c:\\Docs\\Source\\a.txt"
@"""Ahoy!"" cried the captain." // "Ahoy!" cried the captain.
and(!) also as 'marker' that allows to use keywords as identifiers:
class @class
{
public static void @static(bool @bool) {..}
..
}
so, probably it is OK to have backtick also as 'special' string marker in
Swift ?
`abc "def" \(hahaha /// \total-10`
Also, wanted to drop some alternatives:
* what about single quote? like
'abc "def" \(hahaha /// \total-10'
(if single quote appear in text - it should be doubled, so
'example '' - is a "single" quote'
* what about @ like in c# for string literals just to say "do not process
escapes" (double quotes should be doubled) :
@"this just text \( \t \n but with ""double quotes"""
* what about $".."$ to mark a sting as-is, without escapes, without
interpolation, allows double quote without escaping(putting twice)? Yes, "$
combination will not be allowed inside of such string.
On 09.05.2016 1:13, Brent Royal-Gordon via swift-evolution wrote:
>> By the way has the backtick or triple backtick been considered?
>
> Backticks already have a meaning—they "quote" an identifier which would
> otherwise be taken as a keyword.
>
> --
> Brent Royal-Gordon
> Sent from my iPhone
>
> On May 8, 2016, at 2:58 PM, Ricardo Parada <rparada at mac.com
> <mailto:rparada at mac.com>> wrote:
>
>> The _" and "_ are a good alternative I think.
>>
>> For some reason the underscore bothers me: it doesn't look as good
>> aesthetically as others, and because it is already used for a couple of
>> other things in Swift (to make large numbers readable and as a
>> placeholder to discard a value).
>>
>>
>>
>>
>>
>>> On May 7, 2016, at 7:24 PM, L. Mihalkovic <laurent.mihalkovic at gmail.com
>>> <mailto:laurent.mihalkovic at gmail.com>> wrote:
>>>
>>>
>>>
>>> Regards
>>> (From mobile)
>>>
>>>> On May 8, 2016, at 12:49 AM, Ricardo Parada via swift-evolution
>>>> <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>>>
>>>>
>>>>
>>>> It seems to me like this would take care of what is needed 99% of the
>>>> time.
>>>>
>>>> I've seen many who don't favor continuation quotes.
>>>>
>>>> The other option could be triple quote """ and make the continuation
>>>> quote optional. Not using the continuation quote would require the
>>>> closing triple quote """
>>>
>>> For having built a prototype, I've come to realize that there are more
>>> alternatives.
>>>
>>> This is some of my own tests:
>>> https://gist.github.com/lmihalkovic/718d1b8f2ae6f7f6ba2ef8da07b64c1c
>>>
>>> The idea of these M/e or any other similar prefix remind me of my perl
>>> days (there were a lot of these), and IMO have little to do with the
>>> rest of Swift.
>>>
>>>>> On May 7, 2016, at 9:48 AM, Brent Royal-Gordon via swift-evolution
>>>>> <swift-evolution at swift.org <mailto:swift-evolution at swift.org>> wrote:
>>>>>
>>>>> ```
>>>>> // Something like:
>>>>> let xml = M"<?xml version="1.0"?>
>>>>> "<catalog>
>>>>> " <book id="bk101" empty="">
>>>>> " <author>\(author)</author>
>>>>> " </book>
>>>>> "</catalog>
>>>>> ```
>>>> _______________________________________________
>>>> swift-evolution mailing list
>>>> swift-evolution at swift.org <mailto:swift-evolution at swift.org>
>>>> https://lists.swift.org/mailman/listinfo/swift-evolution
>
>
> _______________________________________________
> swift-evolution mailing list
> swift-evolution at swift.org
> https://lists.swift.org/mailman/listinfo/swift-evolution
>
More information about the swift-evolution
mailing list