Added: C# Language Design Notes for May 26, 2017 #690
Replies: 10 comments
-
Option 1 (Improve Some of the "weaknesses" of |
Beta Was this translation helpful? Give feedback.
-
Another objection for 3.2 is that the less efficient/more verbose IL may impact inlining scenarios in the JIT. |
Beta Was this translation helpful? Give feedback.
-
I think as for the objections to 3.1:
Reflection can distinguish, in the same way it distinguishes Dynamic. Users would just need to "know" to look (if it matters in those scenarios).
Not quite sure what the inefficiency here is. It just calls |
Beta Was this translation helpful? Give feedback.
-
I think for the objections to 3.2:
At least on CoreCLR, users can use the |
Beta Was this translation helpful? Give feedback.
-
I am in favor of 3.2. The objections are short-term only, apart from more verbose IL in "couple of cases", but those cases aren't elaborated on. Common cases? Corner cases? |
Beta Was this translation helpful? Give feedback.
-
@miloush, the actual struct would just be a wrapper around This means the JIT has to work 'harder' to inline all these calls (the JIT is generally pretty good about simple wrappers, but there are a few issues where it fails to do the job and it causes significant drops in perf). It also means there is potential IL "bloat", which can impact the JIT in other unforeseen ways (in some cases it could make the method "just big enough" that inlining no longer happens for certain functions). Most of these issues could be worked around, but there may be issues that would require a runtime fix (which means lower perf anywhere these fixes don't exist). |
Beta Was this translation helpful? Give feedback.
-
@tannergooding this does not sound like any existing code would be impacted, more like that a new feature would not be as performant as it theoretically could be, at least at the beginning. That's not a perf drop, that's an initial perf of a new feature which could be later improved upon. |
Beta Was this translation helpful? Give feedback.
-
@miloush, it is new to C# code certainly, but it is not new to the CLR or to any language which does expose the actual operators defined by the runtime spec (such as F# or raw IL). The reason why I, personally, am less favorable of 3.2 are:
and, possibly most importantly; due to the reach of C#, it being used as the primary language for developing CoreFX, etc:
|
Beta Was this translation helpful? Give feedback.
-
Quote from LD notes:
What about "Option 5" =
That means:
Note that the following 3 overloads would still be possible:
.. since I don't understand, why / when / where the extra struct types would be needed ? |
Beta Was this translation helpful? Give feedback.
-
NOTE: The examples below are just examples and may not entirely be what LDM has in mind for that particular option. @MillKaDe, many of the existing methods on The C# language can't just make Option 3 is effectively what you are proposing minus the required metadata/attribute (Also, I'm fairly certain 3.1 and 3.2 are not sub-options but further details on the existing option). Under option 3, if the user were to declare Because attributes are not used in determining the method signature, you could not declare both The magic attribute is what allows the compiler to explicitly determine that a referenced assembly is going to be operating under the new semantics and that the user should explicitly cast when calling the method so that they are aware of the semantic differences. For example, if the user has an If you went with option 2 (new struct wrapper types), you would be in the same scenario (requiring an explicit cast to opt-in to the new semantics). The difference being that with option 3 Both options (3 and 2) would also require, for existing methods that take static IntPtr Add(IntPtr left, IntPtr right)
{
return (nint)(left) + (nint)(right);
} Under option 3, this is only required syntax in the C# code, the IL that is produced can be identical to as if the user had just declared: static nint Add(nint left, nint right)
{
return left + right;
} Now it might be the case that option 2 could be done and the compiler could do a bunch of optimizations to ensure the IL produced is as minimal as possible (accessing the wrapped
|
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
C# Language Design Notes for May 26, 2017
Please discuss.
Beta Was this translation helpful? Give feedback.
All reactions