797 B
797 B
C# Language Design Notes for Sep 6, 2016
Agenda
- How do we select
Deconstruct
methods?
How do we select Deconstruct methods?
(int x, var y) = p
cannot just turn into p.Deconstruct(out int x, out var y)
, because we want it to find a Deconstruct
method with a more specific type than int
, e.g. byte
.
We should look only at the arity of the Deconstruct
method. If there's more than one with the given arity, we fail. If necessary, we will then translate this into passing temporary variables to the Deconstruct
method, instead of the ones declared in the deconstruction. E.g., if p
has
void Deconstruct(out byte x, out byte y) ...;
We would translate it equivalently to:
p.Deconstruct(out byte __x, out byte __y);
(int x, int y) = (__x, __y);