Pointer of a static lambda #4791
Answered
by
333fred
WhiteBlackGoose
asked this question in
Language Ideas
-
So, there are static lambdas, which is great syntax sugar for inlining methods which you don't want to use twice and passing them as lambdas. There are also normal static methods, to which we can get a function pointer for high-performance/PInvoke and anything. So... why not to have pointers to static lambdas? The syntax might look like &static a => 5 The type inference will work based on the target pointer, so e. g. delegate*<int, int> inc = &static a => a + 1; This var inc = &static a => a + 1; is invalid (same way as with normal lambdas). I guess the code delegate*<int, int> inc = &static a => a + 1; will be expanded by Roslyn into delegate*<int, int> inc = &SomethingQuack.Method;
...
static class SomethingQuack
{
internal static int Method(int a) => a + 1;
} So, what do you think? |
Beta Was this translation helpful? Give feedback.
Answered by
333fred
May 29, 2021
Replies: 1 comment 1 reply
-
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
333fred
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
#3476