Thread wrap up
Tomorrow is the end of the review period so Iād like to try to summarise what I have taken from the thread.
Iāve published an updated version of the proposal for discussion here.
Summarising the story so far, this proposal puts forward a syntax for raw string literals which are strings where \
is passed through to the literal and has no special escaping powers. The suggested syntax is now #raw(āa string with a \ā)
rather than rāa string with a \ā
as in the original proposal merged into swift-evolution master at the beginning of this process.
This version of the proposal includes ācustoms delimiters liteā as originally put forward by @hooman at the beginning of the thread and later echoed by @Erica_Sadun.
Removing the āclosing would be reversedā so your favourite emoji works, this would be a valid raw string:
print(#raw(š¤”"SE-200"š¤”))
In addition, the new version of the proposal includes what you could call āinterpolating raw stringsā which ignore escapes except for the sequence \(ā¦)
which can be used to interpolate. I propose the following syntax with double bracketing of the literal to turn this variant on:
print(#raw(("SE-\("200")")))
Revisiting the code which prompted me to start this process I realised it doesnāt take long before you find yourself needing this feature and the sequence \(
is sufficiently rare outside Swift that this shouldnāt be a problem.
You can combine raw literals, custom delimiter syntax and interpolation with multi-line string literals
print(#raw((š¤”"""
SE-\(200)
"""š¤”)))
Multiline raw literals would follow the same indentation removal rules as before.
That about covers it unless there is something Iāve missed. There is a Xcode toolchain with an implementation available here
Iām now firmly of the opinion that #raw(āa literalā)
is about is good as weāre going to get. With any raw literal there is absolutely no way to escape the delimiter, so all single character delimiters (whichever quote you use) are simply not useful in the general case. This excludes rāa stringā
, \āa stringā
, ā\qa stringā
, 'a string'
from contention. You get many more options if you move to #raw(āa stringā)
which has, at a minimum, a closing delimiter of ā)
and you can now extend that using custom delimiter sequences.
To give the core team something to go on, Id like to call a straw poll on this new version of the proposal. Please respond what you would like the outcome to be:
+1: Accepted with revisions - New version of the proposal looks good.
-1: Reject - I donāt see the need for the feature
Apologies for the slightly chaotic progression of the review but I really feel we have explored the space quite thoroughly now and been able to put in front of the Core Team enough information for them to make a decision.