csharplang/meetings/2016/LDM-2016-09-06.md

22 lines
797 B
Markdown
Raw Normal View History

# C# Language Design Notes for Sep 6, 2016
## Agenda
1. 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
``` C#
void Deconstruct(out byte x, out byte y) ...;
```
We would translate it equivalently to:
``` c#
p.Deconstruct(out byte __x, out byte __y);
(int x, int y) = (__x, __y);
```