18 ms·
... Why? There are so many different ways to do strings in C#. Adding features like this just makes the language harder to learn, and the compiler harder to im
by gwbas1c 5y ago
... Why?
There are so many different ways to do strings in C#. Adding features like this just makes the language harder to learn, and the compiler harder to implement.
At this point, it's probably better to adjust the compiler to make it easier to turn a text file into a hardcoded string. The embedded resource approach works, but it could be significantly smoother.
Or, maybe the compiler needs some form of a plugin architecture so people who want obscure features can figure out how to add them?
- eterm 5y agoIt talks about why, because all those different ways require escaping.
- radicalbyte 5y agoBecause it allows us to literally embed other languages within C# and provide full refactoring, tooling support. Next level stuff this (and something which should be normal, it's 2022 ffs!).
- Metasyntactic 5y agoHi. I'm the lang designer and feature implementor. To your question of "why?", we tried to cover the reasoning in teh proposal. But, the core reason is that today people do use strings a ton. And in many cases it's unpleasant to do so because you always end up with reasons that you need to escape the content. This escaping serves to satisfy the compiler, but really doesn't buy value to teh user the majority of the time. The idea here is that you can just use a raw-string and say: here's the content, exactly as i want it.