Replies: 6 comments
-
The decision around the syntax for declaring a record was made under the assumption that structs could probably be automatically considered records due to their existing value equality properties. Now that the gap between records and structs widens due to interface implementations and potentially other members to the extent that the team is leaning towards explicit opt-in via "struct records" where does this leave the previous syntax decision? |
Beta Was this translation helpful? Give feedback.
-
I don't see it really changing things. 'record' is the nice short way to make a normal record. 'struct record' is just a number way to say: I really the same, but it should be a value type |
Beta Was this translation helpful? Give feedback.
-
So rather than This is the approach that Java is taking, but Java's approach makes significantly more sense since |
Beta Was this translation helpful? Give feedback.
-
Currently yes. For people who want value-type records, you use two keywords in both events. However for lots of people where they only want/nee ref-type records, you only need a single one. That's what we opted for as being preferable overall. |
Beta Was this translation helpful? Give feedback.
-
If so, I think I will be using always record structs and recommend for my community members not to use old-fashioned structs anymore except for compatibility reason. |
Beta Was this translation helpful? Give feedback.
-
Ok. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Jun 22, 2020
C# Language Design Notes for June 22, 2020
Data properties
Clarifying what's supported in records for C# 9
Structs
Inheritance with records and classes
with
expressions on non-recordsBeta Was this translation helpful? Give feedback.
All reactions