Replies: 1 comment
-
Here's the section of the spec that I think is relevant since inference of names follows the same rules for tuples as they did for anonymous objects:
|
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
@SergeyTeplyakov commented on Sat Oct 28 2017
Version Used: master
Steps to Reproduce:
The inferred type is
(Sample, int x)
, but could be(Sample @this, int x)
.I work on perf critical application and to avoid closure computation I often pass a tuple into a method similar to
ConcurrentDictionary.GetOrAdd
:And in this case, I have to specify a name of the tuple element manually. I understand that my use case is not that common, but I'm curious is there any specific reason why such inference is not implemented? Or this case was just missed?
@jcouv commented on Sun Oct 29 2017
This is the same behavior as anonymous types:
var x = new { this }; // not allowed
vsvar x = new { @this=this }; // ok
.I think that's currently by design, so I'll move this suggestion to csharplang repo for discussion.
Beta Was this translation helpful? Give feedback.
All reactions