-
Notifications
You must be signed in to change notification settings - Fork 21
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Allow the record pattern to be implemented explicitly #164
Comments
3 tasks
5 tasks
dsyme
changed the title
Copy-and-update on class types and on records of different types.
Implementing the record pattern
Jun 16, 2022
dsyme
changed the title
Implementing the record pattern
Allow the record pattern to be implemented explicitly
Jun 16, 2022
I've renamed this, see also #1152 |
5 tasks
Would the attribute imply structural equality, would such a class otherwise be indistinguishable from a bona fide record? |
The type would have to implement the equality/comparison interfaces |
6 tasks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Submitted by Don Syme on 3/21/2014 12:00:00 AM
25 votes on UserVoice prior to migration
People sometimes find it hard to transition from records to class types - something which comes up when seeking to encapsulate some of the details of the record type. One particular reason for this is because their codebase may uses copy-and-update on record types. One approach to easing the transition would be to support copy-and-update on class types, as long as the class type follows a particular design pattern.
One pattern-based approach could permit both normal record syntax and copy-and-update syntax, e.g.
Whether there were one or two attributes (one for 'RecordSyntax' and one for 'CopyAndUpdateSyntax') would be up for discussion. Presumably using either attribute would give result in a declaration-time check that members exist to match constructor arguments. Matching uppercase properties to lowercase argument names is somewhat inelegant but in the balance is likely to be a reasonable price to pay for following .NET and F# design norms.
Original UserVoice Submission
Archived Uservoice Comments
The text was updated successfully, but these errors were encountered: