Add: allow ref this parameter in extension methods for variables created implicitly by the compiler #8324
Unanswered
marchewek
asked this question in
Language Ideas
Replies: 2 comments 31 replies
-
I mean, it is consistent in that you can't pass that expression to a method that accepts a |
Beta Was this translation helpful? Give feedback.
30 replies
-
You can use the You just have to use |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
First things first to set the context - I find myself very good in object-orientation paradigm and consistency (as a kind of life philosophy), but I never excelled in the low level stuff (main reason I decided to stick with C# instead of C++). Therefore my finding doesn't have to necessarily be a "missing language feature" but simply a "documentation about that low level stuff in C# is poor"-kind-of finding. Please keep that in mind going forward. I'm also not an English-native, so please forgive me any linguistic mistakes I made along the way. This is a follow up to the original post I made in the incorrect repo*.
As pointed out in my original post, the language right now behaves differently for explicit and implicit variables (by implicit I mean a variable created by the compiler in the background):
Now as @stephentoub pointed out in the original post, I could use the "in" indicator for the argument and in my case that actually solved the problem - I never intended to modify the implicit variable. But what if someone actually wants to modify the variable? Why make it inconsistent between an explicit and implicit variable?
Once again, my finding comes mostly from consistency standpoint; if this is something impossible due to technical constraints or I am asking for something that would enable some explicitly-unintended scenarios then maybe improving documentation about this part of language would be good enough.
[EDIT 1]
The OP lacked particular use cases, so here are the two that emerged from the discussion.
Personally I find
ref
here redundant (makes the syntax more complex), but it may be required due to technical constraints (makes the language definition less complex).* sorry about that; those are my baby steps in contributing to C#
Beta Was this translation helpful? Give feedback.
All reactions