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

Add support for raw strings #442

Open
triallax opened this issue May 27, 2024 · 4 comments
Open

Add support for raw strings #442

triallax opened this issue May 27, 2024 · 4 comments

Comments

@triallax
Copy link
Contributor

triallax commented May 27, 2024

This ticket requests adding support for raw strings, inside of which usually special syntax such as string interpolations would be treated as literal parts of the string. Possible forms we could add:

  • r"..." (Python-style)
  • r#"..."# (Rust-style)
  • `...`

I think the Rust syntax is pretty nice because you can add as many #'s as needed to disambiguate the end of the string from its contents (and also because we usually do things the Rust way in Numbat :D).

@sharkdp
Copy link
Owner

sharkdp commented May 27, 2024

I'm fine with adding raw strings to the language eventually. But I'm questioning if this is the right time? Do we have concrete use cases for raw strings?

I tend to use them in unit tests if my code handles large blocks of text (that I want to copy in from somewhere). For smaller strings, I'm usually okay with escaping things by hand.

@eminence
Copy link
Contributor

I think this might have come from a request I made in IRC. I wanted to use numbat to calculate the length of a string, but I couldn't do because the string contained { and } characters.

@triallax
Copy link
Contributor Author

That was what made me think about the issue yeah, but @sharkdp is right that, at least for now, this isn't really important because there aren't any major concrete use cases for it at the moment.

@sharkdp
Copy link
Owner

sharkdp commented May 27, 2024

I couldn't do because the string contained { and } characters.

I remembered the conversation, but not this use case. Given that we don't have Python-style f"…" strings for using formatters, it might be nice to have raw strings after all. I'd say it's okay to implement them now if they don't add too much complexity.

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

No branches or pull requests

3 participants