meetings/2019/LDM-2019-01-23.md
Function pointers (Updated proposal)
The proposal is &Class.Method to produce a function pointer. The question
is whether &Class.Method is target-typed, whether it has a natural type
when there's only one member in the method group, or both.
Target-typing is useful because, like with delegates, it allows you to select a unique method out of a method group with multiple incompatible overloads.
Natural type is useful because it allows things like var and void*.
Conclusion
Let's start by only doing target-typing. Also, the section "better function member" is not necessary without the natural typing.
There is actually a stub that the compiler calls for P/Invoke with DllImport that is always done using the managed calling convention, so there's no reason for function pointers to use the DllImportAttribute.
NativeCallback is intended for the scenario where you want to avoid the stub overhead.
Let's look at this in more detail.
1. func* managed int(string)
2. func*(string)->int
3. func* managed (string)->int
4. func* managed (string)=>int
5. managed int(string)*
5a. int(string)*
6. managed int(string)
7. managed (string)->int
8. delegate* int(string)
9. func int(string)*
10. delegate int(string)*
Conclusion
We're not sure about all the potential ambiguities here. Let's look at (5a), possibly disambiguating with the calling convention.
calli has the signature without the modreq/modopt?