Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Newline escapes in Swift Strings #695

Merged
merged 7 commits into from Jul 12, 2017

Conversation

Projects
None yet
4 participants
@johnno1962
Copy link
Contributor

commented Apr 24, 2017

This is an entirely speculative proposal to introduce newline escapes into all Swift string literals. As was mentioned in the acceptance of 0168-multi-line-string-literals.md:

Discussion on the list raised the idea of allowing a line to end with \ to "escape" the newline and elide it from the value of the literal; the core team had concerns about only allowing that inside multi-line literals and felt that that could also be considered later as an additive feature.

This proposal suggests "later" could be now seeing as we have the covers up on the Lexer at the moment for multiline string literals in Swift4. This is avery minor change for which an implementation is already available.

@DevAndArtist

This comment has been minimized.

Copy link
Contributor

commented Apr 26, 2017

We need to fine tune this proposal more on the mailing-list. It seems most of us are kinda tired from the long discussion we had in the previous proposal. Obviously I'm not good at writing proposals myself, but I'm happy to provide feedback for the drafts.

https://lists.swift.org/pipermail/swift-evolution/Week-of-Mon-20170424/036189.html

@lattner

This comment has been minimized.

Copy link
Collaborator

commented Jul 8, 2017

Hi @johnno1962 , I'm agitating to get the core team to look at this. Please make the following clarifications to the document:

  • Make it clear that horizontal whitespace between the end of the normal line and the \ IS included in the string.
  • Make it clear that any horizontal whitespace between the \ and the newline is NOT included.
  • Please mention that a \ on the line before the final """ is invalid. This is the most conservative approach and eliminates a class of accidental errors.

It would be great if you could show a short example of each of these, just to make sure the proposal is crystal clear. Thank you!

@johnno1962

This comment has been minimized.

Copy link
Contributor Author

commented Jul 8, 2017

Hi Dr @lattner, Thanks for picking this up! I’ve added a couple of notes to clarify treatment of trailing whitespace if elided newlines were adopted for all strings. Can you check that I’ve understood you correctly? There was a separate issue where, if this were adopted, multiline strings could include the trailing newline by default since it could so easilly be removed though I’ve found myself fairly neutral on that in the finish.

@DevAndArtist

This comment has been minimized.

Copy link
Contributor

commented Jul 8, 2017

@johnno1962 Hi John, if you wish David and I will jump in and help with the proposal. After David talked to the core team at WWDC he felt this should be deferred for Swift 4.1 so we kept the silence.

@johnno1962

This comment has been minimized.

Copy link
Contributor Author

commented Jul 8, 2017

Thanks @DevAndArtist, I’ve would have kept the silence if this wasn’t Chris! It’s largely to bring Swift strings into line with C complementing the existing proposal as-is. Do you have any comments?

@DevAndArtist

This comment has been minimized.

Copy link
Contributor

commented Jul 8, 2017

@johnno1962 Any chance you're using Slack so we can stop spamming the thread here. I'll look into our talk with David to remember the conclusion we've arrived at. If not Slack feel free to ping me at: adrian.zubarev@devandartist.com

@DevAndArtist

This comment has been minimized.

Copy link
Contributor

commented Jul 8, 2017

@lattner @johnno1962 it would be good if we could have one day before this proposal is considered for a review. Currently trying to bring @hartbit back into the boat. We'd like to help and fix a couple things.

@lattner

This comment has been minimized.

Copy link
Collaborator

commented Jul 8, 2017

Sounds good, core team meeting is on Wednesday, a few days is no problem, thanks!

@hartbit

This comment has been minimized.

Copy link
Collaborator

commented Jul 10, 2017

@lattner John, Adrian and I had a chat together which culminated in the final version of this proposal. We couldn't agree on wether newline escaping should be allowed in single-line strings or not, but we made sure this version of the proposal represents those points in the Alternatives considered section.

@lattner

This comment has been minimized.

Copy link
Collaborator

commented Jul 12, 2017

Awesome, thank you!

@lattner lattner merged commit b7641b0 into apple:master Jul 12, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.