3 ms·
This is like reading through a list of Christmas presents I didn't even know I wanted. Relational/Logical patterns are going to revolutionize our ability to ma
by bob1029 6y ago
This is like reading through a list of Christmas presents I didn't even know I wanted.
Relational/Logical patterns are going to revolutionize our ability to make high-level business logic even more accessible to non-wizards. The switch expressions introduced in 8.0 were already very nice for building out our complex in-line mapping code. This takes things to a completely different dimension.
I will say that I am a little confused on the role of Record vs Class vs Struct. Do we not already have the ability to declare immutable value types with structs? How does the Record improve on the struct which already exists in the language?
> Structs override this to have “value-based equality”, comparing each field of the struct by calling Equals on them recursively. Records do the same.
Seems like we might be splitting hairs here?
- OkGoDoIt 6y agoI’m also confused on the relationship between records and structs. I’m guessing in practice it has some of the properties of classes and some of the properties of structures, but I worry it’s just going to complicate things. It’s not like all the old structs in the BCL will just go away.
- mmcconnell1618 6y agoWouldn't a Struct be passed by value and Record (as a class) be passed by reference. Kind of strange to pair immutability with pass by reference.
- dgritsko 6y agoIsn't a big distinction of structs the fact that they are value types (and thus allocated on the stack) rather than reference types allocated on the heap?
- joshschreuder 6y agoI asked the .NET Core team this yesterday during one of the Build talks, appearently data records can be defined as either class or struct and take on the same heap/stack allocation semantics as a regular class or struct. My understanding is that structs are not always a good choice depending on the size of the data contained within because they are put on the stack, so having an immutable class record does not necessarily overlap with the use cases for structs. It seems like records are more of a syntactic sugar which gives you a number of pre-defined behaviours such as value comparison and immutability by default (vs. regular classes).