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

RFC: add raw_str macro for raw strings with no interpolation/unescaping #19254

Closed
wants to merge 4 commits into from
Closed

Conversation

kleinhenz
Copy link
Contributor

This implements a raw_str macro that allows input of strings with no interpolation/unescaping as discussed in issue #11567 and #11764. I understand this functionality (as L_str) was removed by commit 7123ad3 following discussion in issue #107. However, I think this merits reconsideration for a couple reasons.

  1. This feature is useful as a base for working with strings that represent code/markup in other languages. This is reimplemented in packages that deal with these situations, e.g. LaTeXStrings, but the core functionality seems sufficiently general to merit inclusion in base.

  2. Although the implementation of raw_str is basically trivial, it has very low discoverability to new users, especially people coming from python who expect to have the functionality builtin. Users wanting to use raw strings shouldn't have to go through stack overflow to implement this functionality themselves.

  3. raw_str is clear, concise and provides a useful base for more complicated use cases. Because raw_str doesn't unescape anything, it is possible to define exactly what you want to unescape in julia, e.g. unescape(raw"...") will unescape traditional c/unicode escape sequences but leave $ escaped and avoid interpolation. This seems much cleaner than some proposals for using string macro suffixes to specify exactly what to unescape. Also to me raw"..." seems more self-documenting than L"..." or '''...''' and adds the minimal amount of additional complexity to the strings ecosystem.

Apologies in advanced if this has already been hashed out beyond the discussions I was able to find, but given the two open issues I thought it was worth submitting a PR to see if we can figure out something that can be merged into master.

@ararslan
Copy link
Member

ararslan commented Nov 7, 2016

If you could add tests for this, that would be great.

@tkelman tkelman added needs tests Unit tests are required for this change needs docs Documentation for this change is required labels Nov 7, 2016
@kleinhenz
Copy link
Contributor Author

Tests/preliminary documentation added.

@kleinhenz kleinhenz closed this Jan 4, 2017
@kleinhenz kleinhenz deleted the raw_string branch January 4, 2017 19:13
@tkelman tkelman removed needs docs Documentation for this change is required needs tests Unit tests are required for this change labels Jan 4, 2017
@tkelman
Copy link
Contributor

tkelman commented Jan 4, 2017

We appear to have let this slip through the cracks without any further review since you added tests and docs. Sorry about that @kleinhenz!

@kleinhenz
Copy link
Contributor Author

No problem, I just closed since I assumed there wasn't interest. I am happy to discuss/develop further if there is interest in adding this or some variant to base.

@KristofferC
Copy link
Sponsor Member

This seems like a well made PR. I'm interested in this because I have written this exact macro a few times locally.

@kleinhenz
Copy link
Contributor Author

Ok, since I prematurely deleted the branch I have created a new PR (#19900). I would appreciate any comments from people who are interested.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants