Record in C# 9 (proposal)

John Rose john.r.rose at oracle.com
Sat Dec 7 01:51:59 UTC 2019


On Dec 6, 2019, at 7:58 AM, Brian Goetz <brian.goetz at oracle.com> wrote:
> 
> Yes, we’ve been watching this one for years — they started on this effort shortly before we started on ours.  Obviously they built a different feature because they have a different language; for example, records interact positively with C# properties.  
> 
> Their chosen design persona is much more of a Billy Boilerplate than a Tommy Tuple.  

+1

They have a clever “with” mechanism.  We might try to do something similar,
but as link-time sugar, not compile-time, so that an invokedynamic handshakes
with one or more “with” link points to update zero or more named components.

IMO the call site linkage should be as complex as the number of read and written
components, not as complex as the whole record.

It could be implemented as the caller passing in a lambda to the callee, who
invokes the lambda on the read components and receives back all the written ones
(multiple value return again!) before returning the updated record instance.
Whatever multiple value return we do for pattern matching is a candidate
here also, although the arrows run in reverse, compared to a match.
Where a “match” pulls out some values from the record, a “with” pushes
them back in.  There’s more, of course, because a “with” will often update
a component, as in `__With mycursor __Update x++;` (not the real
syntax).

— John


More information about the amber-spec-experts mailing list