-
Notifications
You must be signed in to change notification settings - Fork 393
Switching quantity to class from struct #500
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
I'm not too sure about including this one for the 4.0 release? Reference vs value semanticsCan we cause a lot of trouble changing this, such as producing null reference exceptions where they prior relied on default value (zero and base unit)? Is the performance/memory impact significant?Does it add significant CPU overhead when constructing instances? What does
|
I think regarding reference vs value semantics, it's best not to worry too much. You could indeed have null with using classes, but you could before using the nullable types that we removed. In one way, changing to class would allow null to continue to exist for "uninitialized" values while still keeping the library size small. Microsoft has said that the stack vs heap is an implementation detail, and I doubt there's much CPU or memory difference between the two. We could profile to know for sure. In addition to allowing null listed above, it would allow us to use generics as well as inheritance, correct. The interface + struct route does indeed work, but that definitely has performance implications as using an interface on the left-hand-side introduces boxing considerations. |
I think Boxing overhead would be limited to when you work generically with quantities and it would not be any worse than working with I want to pursue this idea further, but I think it's maybe a mistake to shoehorn it into 4.0 since at least for me I'm still too undecided on whether I think this is a better choice or not. Let's focus on wrapping up this release with reasonably small breaking changes and get the binary size down this time around. After that, we can take our time and focus on the bigger picture of how we want to restructure our types and prototype it up before we make a more informed decision on what would be the best? |
Ok, waiting for another time works for me! |
No description provided.