The main issue I have with them for classes is that there's no way to mark the parameters as readonly.
C Sharp
A community about the C# programming language
Getting started
Useful resources
- C# documentation
- C# Language Reference
- C# Programming Guide
- C# Coding Conventions
- .NET Framework Reference Source Code
IDEs and code editors
- Visual Studio (Windows/Mac)
- Rider (Windows/Mac/Linux)
- Visual Studio Code (Windows/Mac/Linux)
Tools
Rules
- Rule 1: Follow Lemmy rules
- Rule 2: Be excellent to each other, no hostility towards users for any reason
- Rule 3: No spam of tools/companies/advertisements
Related communities
I think that’s one of the reasons I like primary constructors - when you see one, it’s a signal that there’s nothing “special” happening with the parameters.
On the other hand… there are like 7 different ways to do constructors at this point (exaggerating a little…) and it’s a lot to keep track of.
I think they especially make sense for records so you can easily create shallow modifyable value semantic types with little boilerplate code.
I do hate that all these features are yet more keywords and weird syntax. It's becoming C##.
Like the records are just sytesized methods on classes or structs. We already have this in the language with source generation. If something there was missing to create records, it would IMO make more sense to improve the source generation so the community also has access to the ecmxtensions. And the record could be split up in it's separate features (copy constructor, defaul ToString imp, equatable) so we could choose to use part of it.
Regarding your point about C##…
It does seem like, in their effort to make the language less Java-y/enterprise-y, we now have multiple syntaxes for everything. I get the desire to maintain backwards compatibility but it does start to make the available range of syntax feel kind of messy.
Me personally? Hate 'em. In every scenario. They force you to break standard naming semantics.