The C# 9.0 with keyword facilitates the creation of new records from existing records.
My question is: what technical reasons did or could motivate introducing this specific feature with a new keyword and syntax instead of just generating a new function with named parameters.
For example consider the example from the docs:
Person person1 = new("Nancy", "Davolio") { PhoneNumbers = new string[1] };
Person person2 = person1 with { FirstName = "John" };
Instead we could have had something like:
var person1 = new Person("Nancy", "Davolio", new string[1]);
var person2 = person1.With(FirstName:"John");
I assume that adding new syntax to a widely used language like C# based on careful consideration and that possibly it is documented somewhere.

How would you implement this
Withmethod? Let's make a try:The problem with this approach is that we are not able to set a field to null as in
Therefore another approach is required. We could add overloads of every possible parameter combination
The problem is that the number of required overloads grows exponentially with the number of parameters:
Yet another approach would be to let the compiler handle a call like
person1.With(FirstName:"John"). It would be syntactic sugar for compiler generated code. This introduces other problems:Some interesting links relating to the implementation of Non-destructive mutation (
withkeyword):