3 ms·
I always found these complex indentation-stripping rules to be confusing in a language such as Python. I was under the impression that C# doesn't treat whitespa
by assbuttbuttass 5y ago
I always found these complex indentation-stripping rules to be confusing in a language such as Python. I was under the impression that C# doesn't treat whitespace significantly, so why do they need all these complex rules? Just interpret what's between the quotes literally.
- Deukhoofd 5y agoWhen you have multiline strings, and don't want to start the lines with whitespace, it means you need to break the indentation of your code, which can look quite ugly. I'm not sure whether I want the compiler to do it like in the proposal though, I feel like it can easily cause unintentional issues.
- LandR 5y agoWhen I have strings like this, currently I find myself doing something like var foo = "<foo>" + Environment.NewLine + " <bar>" + Environment.NewLine + " <quax>" + Environment.NewLine + "</foo>"; This would fix stuff like this nicely, but it's horrible syntax I think.
- Deukhoofd 5y agoThat would also not be a compile time constant, which would probably be desired in cases like that.
- assbuttbuttass 5y agoI think breaking the indentation is the lesser of two evils, because it becomes very obvious what the content of the string is. I've never minded it too much personally in go, but I guess it's subjective.
- LandR 5y ago> C# doesn't treat whitespace as signficant It doesn't for code, it does for strings. If you have: var foo = "<foo> <bar> <quax> </foo>"; That string is actually <foo> <bar> <quax> </foo> In raw string form, as per the proposal, the string would be: <foo> <bar> <quax> </foo> It allows you to write strings nicely inline, and the indentation in the string itself doesn't matter.