csharplang/meetings/2020/LDM-2020-02-24.md

42 lines
1.5 KiB
Markdown
Raw Normal View History

2020-02-26 19:04:54 +01:00
# C# Language Design for Feb. 24, 2020
## Agenda
1. Nominal records proposal
## Discussion
### Nominal records
https://github.com/dotnet/csharplang/issues/3226
We've been trying to leave space open for something we're calling "nominal records" where the
2020-03-23 16:40:03 +01:00
concept is that we establish some new system for constructing types based on names, instead of
2020-02-26 19:04:54 +01:00
the order of parameters in a constructor.
Here we have a refreshed nominal records proposal to examine and consider.
The proposal says:
> The main thing you lose out on with nominal construction is a centralized place - the
constructor body - for validation. Property setters can have member-wise validation, but
cross-member holistic validation is not possible. However, for a feature such as records that is
for data not behaviors, that seems to be a particularly small sacrifice.
We don't necessarily agree that this is a small restriction, and there may be some way to add
support for it.
When it comes to the `With` we do need to decide what members are copied over in non-destructive
mutation. One strategy is to use the "surface area" of the object, which is defined as the
constructor parameters, along with the public fields and properties that have some sort of
"setter".
Alternatively, we could copy over the state of the object. This would be equivalent to the use
of the `MemberwiseClone` approach as we discussed in previous design meetings.
**Conclusion**
There are many details to work out, but there's consensus that we want to investigate adding
2020-03-23 16:40:03 +01:00
nominal records in the future.