Open jnm2 opened 7 years ago
IL has no concept of custom operators. The op_Whatever
convention is simply one established and understood between the various compilers. Even then not all compilers agree exactly on those operator conventions which is why some languages have operators that others don't.
Oh, nevermind. Reading that again what you're looking for is that convention, at least as it relates to C#.
You might want to ask on the VB.NET and F# forums too as their answers will be slightly different.
The ECMA CLI spec does contain informative mapping between operator names and C++ operators, in §I.10.3 Operator overloading.
Those C++ operators are largely the same as C# operators, but I understand if that's not good enough for you.
Maybe this shouldn't be part of the C# spec, but it could be part of Roslyn's documentation?
IL has no concept of custom operators.
IL doesn't, but the runtime spec (ECMA 335) does. It actually defines a number of "well-defined names". Most of which are supported by C#, but several of which (such as op_PointerDereference
) are not. You can see Section I.10.3 Operator Overloading
for more details.
Reviewed, and not moving to dotnet/csharpstandard. This shouldn't be part of the language standard, but should be documented elsewhere.
Best I can tell, the C# language spec doesn't specify how custom operators are translated to and from IL.
I wanted an exhaustive list of all specially-recognized operator method names (e.g.
op_Modulus
). The only place anyop_*
names show up in the spec is in explaining how to target operators in doc comments.