# multi-line string literals.

(Ted van Gaalen) #1

This could be a simple solution:

Starting each line with a special token.

In the example here it is the \\ double-backslash .
when the \\ appears in the first two columns of a source line,
this tells the compiler that it is a data line and that more might follow.
the last line starting with \\ completes the data entry.

Here is an example of a string declaration with some XML
(no escape sequences needed for “)
Of course it could be anything other kind of textual data as well.

let str =
\\<!DOCTYPE html>
\\<html>
\\<body>
\\
\\<h1>W3Schools Internal Note</h1>\n
\\<div>
\\<b>To:</b> <span id="to"></span><br>\n
\\<b>From:</b> <span id="from"></span><br>\n
\\<b>Message:</b> <span id="message"></span>
\\</div>
\\\n
\\<script>
\\var txt, parser, xmlDoc;
\\txt = "<note>" +
\\"<to>Tove</to>" +
\\etc. this is the last data line.

Conditions:

- Every line starting with \\ in first and second column of the line
is treated as a data line.
- All characters behind the \\ are regarded as data, thus note that:
- the “ is not regarded as a string delimiter
- the // chars and whatever follows it are interpreted as data on such a line, not as comment.
- \\ within the data itself are treated as data e.g. this line is valid:
\\There \\ are three backslashes (as data) in this line \\\\ today.
\\
the above data line is empty but is allowed.

- Leading and embedded spaces are respected.
- Tabs, Linefeeds etc. can be inserted the usual way using \t \n etc.
- trailing spaces and line terminators cr lf are ignored, filtered out.

let dutchNumbers =
\\ een twee drie vier vijf

\\ zes zeven acht negen tien
\\these two data lines are orphans,

Blank lines or other Swift statement lines in-between
breaks a set of \\ data lines

All \\ lines together are treated as one single string literal
and may occur everywhere where “normal” string literals are allowed.

// E.g. this if statement would be correct:
// Yes, this would be legal but doesn’t look so great: Indentation not possible here
if cars ==
\\Ford
\\ Delorean
\\ Chevrolet
{
doSomething()
}

An array with 2 string elements:

var ar =
[
\\sdkdslkdslkdsldkshfkjdljfsdljkfdshjklfd dioioioioio \n\nsljkf sdflkf dsl;dfsk sdlfk dfsfkds
\\ sdkdfkdfldkfd fdfldk fdlkfd jkfds hjklfd dsljkf sdflkf dsl;dfsk sdlfk dfsfkds

···

,
\\There are many ships in the ha
\\rbour that are soon sailing away.
]

I also thought about using “” as token, but this would be interpreted as an empty string.
or “”” but this is an empty string followed by an unclosed string literal.

Should be relatively easy to implement? What y’all think?

Kind Regards
TedvG

(Ted van Gaalen) #2

possible improvement, one could allow
leading spaces before the "data line token"
thus enabling indentation, like so
{
let str =
\\dataaaaaaaaaahgdfhhfdxfg cvcsffggcfg
\\c jggjvhfh fhffhfgxfxgdgfhgj jvhhfhfhcgxgc
.
.
}

TedvG

···

On 25 Apr 2016, at 20:47, Ted F.A. van Gaalen <tedvgiosdev@gmail.com> wrote:

This could be a simple solution:

Starting each line with a special token.

In the example here it is the \\ double-backslash .
when the \\ appears in the first two columns of a source line,
this tells the compiler that it is a data line and that more might follow.
the last line starting with \\ completes the data entry.

Here is an example of a string declaration with some XML
(no escape sequences needed for “)
Of course it could be anything other kind of textual data as well.

let str =
\\<!DOCTYPE html>
\\<html>
\\<body>
\\
\\<h1>W3Schools Internal Note</h1>\n
\\<div>
\\<b>To:</b> <span id="to"></span><br>\n
\\<b>From:</b> <span id="from"></span><br>\n
\\<b>Message:</b> <span id="message"></span>
\\</div>
\\\n
\\<script>
\\var txt, parser, xmlDoc;
\\txt = "<note>" +
\\"<to>Tove</to>" +
\\etc. this is the last data line.

Conditions:

- Every line starting with \\ in first and second column of the line
is treated as a data line.
- All characters behind the \\ are regarded as data, thus note that:
- the “ is not regarded as a string delimiter
- the // chars and whatever follows it are interpreted as data on such a line, not as comment.
- \\ within the data itself are treated as data e.g. this line is valid:
\\There \\ are three backslashes (as data) in this line \\\\ today.
\\
the above data line is empty but is allowed.

- Leading and embedded spaces are respected.
- Tabs, Linefeeds etc. can be inserted the usual way using \t \n etc.
- trailing spaces and line terminators cr lf are ignored, filtered out.

let dutchNumbers =
\\ een twee drie vier vijf

\\ zes zeven acht negen tien
\\these two data lines are orphans,

Blank lines or other Swift statement lines in-between
breaks a set of \\ data lines

All \\ lines together are treated as one single string literal
and may occur everywhere where “normal” string literals are allowed.

// E.g. this if statement would be correct:
// Yes, this would be legal but doesn’t look so great: Indentation not possible here
if cars ==
\\Ford
\\ Delorean
\\ Chevrolet
{
doSomething()
}

An array with 2 string elements:

var ar =
[
\\sdkdslkdslkdsldkshfkjdljfsdljkfdshjklfd dioioioioio \n\nsljkf sdflkf dsl;dfsk sdlfk dfsfkds
\\ sdkdfkdfldkfd fdfldk fdlkfd jkfds hjklfd dsljkf sdflkf dsl;dfsk sdlfk dfsfkds
,
\\There are many ships in the ha
\\rbour that are soon sailing away.
]

I also thought about using “” as token, but this would be interpreted as an empty string.
or “”” but this is an empty string followed by an unclosed string literal.

Should be relatively easy to implement? What y’all think?

Kind Regards
TedvG

(Michael Peternell) #3

"""Just in my opinion:
having to start each line with a particular token kinda defeats the purpose of multiline string literals.
"can't we just continue"
"the literal on the next line anyways,"
"like in C?"
"or maybe the "+
"at the end of the line can be"+
"optimized away?"
"""

What is wrong with just using """ as a delimiter? Except that maybe there are other languages which use this already. You can copy&paste whole XML snippets into such a thing. It's also good for usage instructions in a command line tool, and I think everyone will understand what it means. Is it a design goal to do something completely new? Or are you just unhappy with all existing multi-line string literal syntaxes?

-Michael (who would be happy with Perl Heredoc-Syntax as well)

···

Am 26.04.2016 um 01:00 schrieb ted van gaalen via swift-evolution <swift-evolution@swift.org>:

possible improvement, one could allow
leading spaces before the "data line token"
thus enabling indentation, like so
{
let str =
\\dataaaaaaaaaahgdfhhfdxfg cvcsffggcfg
\\c jggjvhfh fhffhfgxfxgdgfhgj jvhhfhfhcgxgc
.
.
}

TedvG

On 25 Apr 2016, at 20:47, Ted F.A. van Gaalen <tedvgiosdev@gmail.com> wrote:

This could be a simple solution:

Starting each line with a special token.

In the example here it is the \\ double-backslash .
when the \\ appears in the first two columns of a source line,
this tells the compiler that it is a data line and that more might follow.
the last line starting with \\ completes the data entry.

Here is an example of a string declaration with some XML
(no escape sequences needed for “)
Of course it could be anything other kind of textual data as well.

let str =
\\<!DOCTYPE html>
\\<html>
\\<body>
\\
\\<h1>W3Schools Internal Note</h1>\n
\\<div>
\\<b>To:</b> <span id="to"></span><br>\n
\\<b>From:</b> <span id="from"></span><br>\n
\\<b>Message:</b> <span id="message"></span>
\\</div>
\\\n
\\<script>
\\var txt, parser, xmlDoc;
\\txt = "<note>" +
\\"<to>Tove</to>" +
\\etc. this is the last data line.

Conditions:

- Every line starting with \\ in first and second column of the line
is treated as a data line.
- All characters behind the \\ are regarded as data, thus note that:
- the “ is not regarded as a string delimiter
- the // chars and whatever follows it are interpreted as data on such a line, not as comment.
- \\ within the data itself are treated as data e.g. this line is valid:
\\There \\ are three backslashes (as data) in this line \\\\ today.
\\
the above data line is empty but is allowed.

- Leading and embedded spaces are respected.
- Tabs, Linefeeds etc. can be inserted the usual way using \t \n etc.
- trailing spaces and line terminators cr lf are ignored, filtered out.

let dutchNumbers =
\\ een twee drie vier vijf

\\ zes zeven acht negen tien
\\these two data lines are orphans,

Blank lines or other Swift statement lines in-between
breaks a set of \\ data lines

All \\ lines together are treated as one single string literal
and may occur everywhere where “normal” string literals are allowed.

// E.g. this if statement would be correct:
// Yes, this would be legal but doesn’t look so great: Indentation not possible here
if cars ==
\\Ford
\\ Delorean
\\ Chevrolet
{
doSomething()
}

An array with 2 string elements:

var ar =
[
\\sdkdslkdslkdsldkshfkjdljfsdljkfdshjklfd dioioioioio \n\nsljkf sdflkf dsl;dfsk sdlfk dfsfkds
\\ sdkdfkdfldkfd fdfldk fdlkfd jkfds hjklfd dsljkf sdflkf dsl;dfsk sdlfk dfsfkds
,
\\There are many ships in the ha
\\rbour that are soon sailing away.
]

I also thought about using “” as token, but this would be interpreted as an empty string.
or “”” but this is an empty string followed by an unclosed string literal.

Should be relatively easy to implement? What y’all think?

Kind Regards
TedvG

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

(Ted van Gaalen) #4

Hi Michael

What happens if a delimiter in this case: “””
occurs embedded in the data? like so (two times here):

“””
dfksposdkj dslkd s hfdslk dskdslk lskd sk aaasd
lfsdlks dslksd sdlk sdlksd “”” fskfsdalkfsd “”” fdjf dkjfds
“”"

Having a particular token at the start of a line (or after leading space(s) ) to define a data line
allows us to use *all* available characters behind it.

Actually after further thinking, I assume that 1 token is not enough, perhaps there should be two tokens e.g.

\\ ……………... to process escaped chars, like \… and \(item),
the same way as with normal Swift string literals

\@…………. to take all characters as is without conversion?

Examples:
1.
let someText =
\\There are \t \t \(nrofboxes) boxes avai
\\lable.
converts to:
"There are 12 boxes available."

2.

let someText =
\@There are \t \t \(nrofboxes) boxes avai
\@able.
String taken as is, nothing is converted:
"There are \t \t \(nrofboxes) boxes available."

Of course one could choose other tokens than \\ and \@
they just looked convenient to me...

TedvG

"""Just in my opinion:
having to start each line with a particular token kinda defeats the purpose of multiline string literals.

Why?

···

On 26.04.2016, at 07:53, Michael Peternell <michael.peternell@gmx.at> wrote:
"can't we just continue"
"the literal on the next line anyways,"
"like in C?"
"or maybe the "+
"at the end of the line can be"+
"optimized away?"
"""

What is wrong with just using """ as a delimiter? Except that maybe there are other languages which use this already. You can copy&paste whole XML snippets into such a thing. It's also good for usage instructions in a command line tool, and I think everyone will understand what it means. Is it a design goal to do something completely new? Or are you just unhappy with all existing multi-line string literal syntaxes?

-Michael (who would be happy with Perl Heredoc-Syntax as well)

Am 26.04.2016 um 01:00 schrieb ted van gaalen via swift-evolution <swift-evolution@swift.org>:

possible improvement, one could allow
leading spaces before the "data line token"
thus enabling indentation, like so
{
let str =
\\dataaaaaaaaaahgdfhhfdxfg cvcsffggcfg
\\c jggjvhfh fhffhfgxfxgdgfhgj jvhhfhfhcgxgc
.
.
}

TedvG

On 25 Apr 2016, at 20:47, Ted F.A. van Gaalen <tedvgiosdev@gmail.com> wrote:

This could be a simple solution:

Starting each line with a special token.

In the example here it is the \\ double-backslash .
when the \\ appears in the first two columns of a source line,
this tells the compiler that it is a data line and that more might follow.
the last line starting with \\ completes the data entry.

Here is an example of a string declaration with some XML
(no escape sequences needed for “)
Of course it could be anything other kind of textual data as well.

let str =
\\<!DOCTYPE html>
\\<html>
\\<body>
\\
\\<h1>W3Schools Internal Note</h1>\n
\\<div>
\\<b>To:</b> <span id="to"></span><br>\n
\\<b>From:</b> <span id="from"></span><br>\n
\\<b>Message:</b> <span id="message"></span>
\\</div>
\\\n
\\<script>
\\var txt, parser, xmlDoc;
\\txt = "<note>" +
\\"<to>Tove</to>" +
\\etc. this is the last data line.

Conditions:

- Every line starting with \\ in first and second column of the line
is treated as a data line.
- All characters behind the \\ are regarded as data, thus note that:
- the “ is not regarded as a string delimiter
- the // chars and whatever follows it are interpreted as data on such a line, not as comment.
- \\ within the data itself are treated as data e.g. this line is valid:
\\There \\ are three backslashes (as data) in this line \\\\ today.
\\
the above data line is empty but is allowed.

- Leading and embedded spaces are respected.
- Tabs, Linefeeds etc. can be inserted the usual way using \t \n etc.
- trailing spaces and line terminators cr lf are ignored, filtered out.

let dutchNumbers =
\\ een twee drie vier vijf

\\ zes zeven acht negen tien
\\these two data lines are orphans,

Blank lines or other Swift statement lines in-between
breaks a set of \\ data lines

All \\ lines together are treated as one single string literal
and may occur everywhere where “normal” string literals are allowed.

// E.g. this if statement would be correct:
// Yes, this would be legal but doesn’t look so great: Indentation not possible here
if cars ==
\\Ford
\\ Delorean
\\ Chevrolet
{
doSomething()
}

An array with 2 string elements:

var ar =
[
\\sdkdslkdslkdsldkshfkjdljfsdljkfdshjklfd dioioioioio \n\nsljkf sdflkf dsl;dfsk sdlfk dfsfkds
\\ sdkdfkdfldkfd fdfldk fdlkfd jkfds hjklfd dsljkf sdflkf dsl;dfsk sdlfk dfsfkds
,
\\There are many ships in the ha
\\rbour that are soon sailing away.
]

I also thought about using “” as token, but this would be interpreted as an empty string.
or “”” but this is an empty string followed by an unclosed string literal.

Should be relatively easy to implement? What y’all think?

Kind Regards
TedvG

_______________________________________________
swift-evolution mailing list
swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

Please allow me to add my 2 cents. How I think about multi-line feature: it should allow to paste any text as-is, which will have no any special letters/symbols in it. Such text should be copied to variable *exactly* as typed inside source file.

I want to be able to have in source file exactly this text, without any wrapping of "disallowed" symbols :

<?xml version="1.0"?>
<catalog>
<book id="myid" empty="">
<author>myAuthor</author>
<title>myTitle \tutorial 1\(edition 2)</title>
</book>
</catalog>

(please note this "\tuttorial" and "\(edition" )

So, I suggest to start such multi line with "\ and have " as end-of-multiline marker:

var xml = "\
<?xml version="1.0"?>
<catalog>
<book id="myid" empty="">
<author>myAuthor</author>
<title>myTitle \tutorial 1\(edition 2)</title>
</book>
</catalog>
"

Pros:
* text as-is, you can have " \ \\ \t \( etc symbols
* var xml = " - clearly seems like start of string, all the lines looks like inside one string
* "\ - says that here is some special case, as we usually need some symbol after \ to have special character like \t or \n
* ends with " - clearly see that here is an end of string (probably "; should be required here.)

Cons:
* if we need tabs inside our 'xml' variable - we need to keep them in source file
* spaces at the end of each line could be trimmed by editor
* line with only " symbol is not allowed inside mutli-line string - it will terminate the string.

But the cons could be solved (if you need this) by custom markers you can use to replace later in 'xml' variable like:
var multiline = "\
#tab<folder>
#tab#tab<file>...</file>
#tab</folder>
"
multiline.replace("#tab", to:"\t")

···

On 26.04.2016 8:53, Michael Peternell via swift-evolution wrote:

"""Just in my opinion: having to start each line with a particular token
kinda defeats the purpose of multiline string literals. "can't we just
continue" "the literal on the next line anyways," "like in C?" "or maybe
the "+ "at the end of the line can be"+ "optimized away?" """

What is wrong with just using """ as a delimiter? Except that maybe
there are other languages which use this already. You can copy&paste
whole XML snippets into such a thing. It's also good for usage
instructions in a command line tool, and I think everyone will
understand what it means. Is it a design goal to do something completely
new? Or are you just unhappy with all existing multi-line string literal
syntaxes?

>

-Michael (who would be happy with Perl Heredoc-Syntax as well)

Am 26.04.2016 um 01:00 schrieb ted van gaalen via swift-evolution >> <swift-evolution@swift.org>:

possible improvement, one could allow leading spaces before the "data
line token" thus enabling indentation, like so { let str =
\\dataaaaaaaaaahgdfhhfdxfg cvcsffggcfg \\c jggjvhfh fhffhfgxfxgdgfhgj
jvhhfhfhcgxgc . . }

TedvG

On 25 Apr 2016, at 20:47, Ted F.A. van Gaalen <tedvgiosdev@gmail.com> >> wrote:

This could be a simple solution:

Starting each line with a special token.

In the example here it is the \\ double-backslash . when the \\
appears in the first two columns of a source line, this tells the
compiler that it is a data line and that more might follow. the last
line starting with \\ completes the data entry.

Here is an example of a string declaration with some XML (no escape
sequences needed for “) Of course it could be anything other kind of
textual data as well.

let str = \\<!DOCTYPE html> \\<html> \\<body> \\ \\<h1>W3Schools
Internal Note</h1>\n \\<div> \\<b>To:</b> <span
id="to"></span><br>\n \\<b>From:</b> <span id="from"></span><br>\n
\\<b>Message:</b> <span id="message"></span> \\</div> \\\n
\\<script> \\var txt, parser, xmlDoc; \\txt = "<note>" +
\\"<to>Tove</to>" + \\etc. this is the last data line.

Conditions:

- Every line starting with \\ in first and second column of the line
is treated as a data line. - All characters behind the \\ are
regarded as data, thus note that: - the “ is not regarded as a
string delimiter - the // chars and whatever follows it are
interpreted as data on such a line, not as comment. - \\ within
the data itself are treated as data e.g. this line is valid: \\There
\\ are three backslashes (as data) in this line \\\\ today. \\ the
above data line is empty but is allowed.

- Leading and embedded spaces are respected. - Tabs, Linefeeds etc.
can be inserted the usual way using \t \n etc. - trailing spaces and
line terminators cr lf are ignored, filtered out.

let dutchNumbers = \\ een twee drie vier vijf

\\ zes zeven acht negen tien \\these two data lines are orphans,

Blank lines or other Swift statement lines in-between breaks a set
of \\ data lines

All \\ lines together are treated as one single string literal and
may occur everywhere where “normal” string literals are allowed.

// E.g. this if statement would be correct: // Yes, this would be
legal but doesn’t look so great: Indentation not possible here if
cars == \\Ford \\ Delorean \\ Chevrolet { doSomething() }

An array with 2 string elements:

var ar = [ \\sdkdslkdslkdsldkshfkjdljfsdljkfdshjklfd dioioioioio
\n\nsljkf sdflkf dsl;dfsk sdlfk dfsfkds \\ sdkdfkdfldkfd fdfldk
fdlkfd jkfds hjklfd dsljkf sdflkf dsl;dfsk sdlfk dfsfkds , \\There
are many ships in the ha \\rbour that are soon sailing away. ]

I also thought about using “” as token, but this would be
interpreted as an empty string. or “”” but this is an empty string
followed by an unclosed string literal.

Should be relatively easy to implement? What y’all think?

Kind Regards TedvG

_______________________________________________ swift-evolution
mailing list swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

_______________________________________________ swift-evolution mailing
list swift-evolution@swift.org
https://lists.swift.org/mailman/listinfo/swift-evolution

(Michael Peternell) #6

Hi Michael

What happens if a delimiter in this case: “””
occurs embedded in the data? like so (two times here):

that's a problem you always have. And I think pasting a few lines of text is a (much) more common use case than wanting to have a string literal that contains """ in it. I have never needed a string literal that contained """, and as long as you don't create a parser for a language that wants to parse such literals, the use cases are very rare IMO. Furthermore, if the string interpolation and escape sequences are enabled, I can answer this directly: you write """some text
some text. Here you have 3 double quotes: ""\" and here again \"""
"""; you can just put a backslash before one of the offending double quotes.

I think starting each line with \\ is really ugly, and I wouldn't consider this a true "multi-line string literal". Because instead of writing

\\bla bla
\\bla bla

I'd rather write

"bla bla\n"
"bla bla"

“””
dfksposdkj dslkd s hfdslk dskdslk lskd sk aaasd
lfsdlks dslksd sdlk sdlksd “”” fskfsdalkfsd “”” fdjf dkjfds
“”"

Having a particular token at the start of a line (or after leading space(s) ) to define a data line
allows us to use *all* available characters behind it.

Actually after further thinking, I assume that 1 token is not enough, perhaps there should be two tokens e.g.

\\ ……………... to process escaped chars, like \… and \(item),
the same way as with normal Swift string literals

\@…………. to take all characters as is without conversion?

Examples:
1.
let someText =
\\There are \t \t \(nrofboxes) boxes avai
\\lable.
converts to:
"There are 12 boxes available."

really? so I have to write \n if I want to have a newline?

2.

let someText =
\@There are \t \t \(nrofboxes) boxes avai
\@able.
String taken as is, nothing is converted:
"There are \t \t \(nrofboxes) boxes available."

Of course one could choose other tokens than \\ and \@
they just looked convenient to me...

TedvG

"""Just in my opinion:
having to start each line with a particular token kinda defeats the purpose of multiline string literals.

Why?

because IMHO the purpose of multiline string literals *is* that you can copy&paste multiple lines of text directly into the editor? If I call \\literals a 'multi-line literal', I can call "normal strings" multiline too, can't I?

What makes
\\this
\\string
a 'multiline string literal'
"and this "
"string"
not? (What is the definition of a "multiline string literal"?)

-Michael

···

Am 26.04.2016 um 15:32 schrieb Ted F.A. van Gaalen <tedvgiosdev@gmail.com>:

On 26.04.2016, at 07:53, Michael Peternell <michael.peternell@gmx.at> wrote:

(Ted van Gaalen) #7

Hi Michael
also inline

Hi Michael

What happens if a delimiter in this case: “””
occurs embedded in the data? like so (two times here):

that's a problem you always have.

It is not a problem with the "data line" method that I suggest...

And I think pasting a few lines of text is a (much) more common use case than wanting to have a string literal that contains """ in it.

..all you have to do is paste your few lines of text an put \@ in front of each line...
** (see further in text)

If copying larger texts, it might be better to use a resource (file) instead of
hard coding all that data into a multi-line string.

I have never needed a string literal that contained """, and as long as you don't create a parser for a language that wants to parse such literals, the use cases are very rare IMO.

Swift is a general purpose language used for making many different applications..

Furthermore, if the string interpolation and escape sequences are enabled, I can answer this directly: you write """some text
some text. Here you have 3 double quotes: ""\" and here again \"""
"""; you can just put a backslash before one of the offending double quotes.

then you would have to change all the " in say an Xml group of lines.

I think starting each line with \\ is really ugly,

Ok, but that's just a matter of personal taste...
I'll gladly give up some esthetics for better functionality.

and I wouldn't consider this a true "multi-line string literal". Because instead of writing

\\bla bla
\\bla bla

I'd rather write

this:

"bla bla\n"
"bla bla"

already exists with + ... +
but then you have to add \n as well and use escape \" all the time.
e.g. when coding Html lines with parameters.

···

On 26 Apr 2016, at 22:05, Michael Peternell <michael.peternell@gmx.at> wrote:

Am 26.04.2016 um 15:32 schrieb Ted F.A. van Gaalen <tedvgiosdev@gmail.com>:

“””
dfksposdkj dslkd s hfdslk dskdslk lskd sk aaasd
lfsdlks dslksd sdlk sdlksd “”” fskfsdalkfsd “”” fdjf dkjfds
“”"

Having a particular token at the start of a line (or after leading space(s) ) to define a data line
allows us to use *all* available characters behind it.

Actually after further thinking, I assume that 1 token is not enough, perhaps there should be two tokens e.g.

\\ ……………... to process escaped chars, like \… and \(item),
the same way as with normal Swift string literals

\@…………. to take all characters as is without conversion?

Examples:
1.
let someText =
\\There are \t \t \(nrofboxes) boxes avai
\\lable.
converts to:
"There are 12 boxes available."

really? so I have to write \n if I want to have a newline?

**
Yes, because here, \\ is used instead of other suggested token \@
but respecting source-file-linefeeds could perhaps be an option
when using \@ ?

2.

let someText =
\@There are \t \t \(nrofboxes) boxes avai
\@able.
String taken as is, nothing is converted:
"There are \t \t \(nrofboxes) boxes available."

Of course one could choose other tokens than \\ and \@
they just looked convenient to me...

TedvG

On 26.04.2016, at 07:53, Michael Peternell <michael.peternell@gmx.at> wrote:

"""Just in my opinion:
having to start each line with a particular token kinda defeats the purpose of multiline string literals.

Why?

because IMHO the purpose of multiline string literals *is* that you can copy&paste multiple lines of text directly into the editor? If I call \\literals a 'multi-line literal', I can call "normal strings" multiline too, can't I?

What makes
\\this
\\string
a 'multiline string literal'
"and this "
"string"
not? (What is the definition of a "multiline string literal"?)

-Michael

Regards, TedvG