On Friday, 16 July 2021 at 13:54:36 UTC, vit wrote:
On Wednesday, 14 July 2021 at 23:16:05 UTC, Dylan Graham wrote:
[DUB](https://code.dlang.org/packages/record)
[Github](https://github.com/hmmdyl/record)
This is record. It aims to implement records similar to what
C# has by leveraging D's metaprogramming. [C# Example
1](https://docs.microsoft.com/en-us/dotnet/csharp/fundamentals/types/records) [C# Example 2](https://docs.microsoft.com/en-us/dotnet/csharp/whats-new/tutorials/records).
Future steps are going to be adding a record struct; default
value support; init-only-setters like in C#, wherein at the
end of construction or duplication, the init lambda for the
field is called, and the field can be set that once.
What adventage has record over normal immutable/const class?
In terms of mutability, none.
The duplicate method, however, lets you copy and mutate (once at
duplication) a record without impacting the integrity of the
original. You can do this with an immutable class, but then you
have to roll your own.
Really, it's more a convenience / less typing sort of feature, as
it implements all the common boilerplate for you, which should
help with consistency of code.