Open triallax opened 5 months ago
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.
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.
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.
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.
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).