Follow

I hate that C++ const nonsense is leaking into C#

@pyredrid Yeah, like if you have a struct that the runtime considers to be readonly (readonly keyword, passing as in parameter, etc.), then the runtime implicitly operates on a copy of it for _operations_ that haven't been marked readonly, meaning that you need to start marking _methods_ as readonly if you don't want implicit copies occurring everywhere…

@Tak @pyredrid That's terrible, but I'd argue it's not much a "const" issue but more an "implicit/hidden operations" issue (the parallel with C++ would be copy-constructors probably).

I doubt C# was ever a language about performance though, so I'm hardly surprised to hear that.

@silverweed @pyredrid
Right, what I meant by "const nonsense" is that the code will be sprinkled with (potentially semantically diffferent) usages of the readonly keyword, similar to const in C++.

const Blah& LookupBlah(const Key& key) const;

readonly ref readonly Blah LookupBlah(in Key key) => …

@Tak @pyredrid Ah yes, that doesn't make much sense for a language like C#, it just adds noise

Sign in to participate in the conversation
Gamedev Mastodon

The social network of the future: No ads, no corporate surveillance, ethical design, and decentralization! Own your data with Mastodon!