Reading through the spec for C# 9.0 I came across record
and the new with
expression. Immediately I thought this was great for all my immutable structs, such as vectors and matrices! However it turns out that the with
expression only works on records. How come? Does the with
expression require something that only a record
is guaranteed to have (equality members perhaps)?
I can understand the argument that structs don't need it since they are value types and simply assigning the value to a new variable is enough to create a copy, but the syntax would be nice and surely it would be useful to create copies like that even for normal classes, not just records?