I understand the benefits of option , but in this case I want to avoid using option for performance reasons. option wraps the type in the class, which means more work for the garbage collector - and I want to avoid that.
In this case, in particular, I have several fields, all Some under the same circumstances, but I do not want to put them in a tuple, because, again, tuples are classes - and it puts extra effort on the GC. So I get access to field.Value - which defeats the option target.
So, if there is no optimization that I donβt know about, it causes option types to be treated as links that are potentially null, I just want to use null . Is there a way I can do this?
Edit: To expand on what I'm doing, I am creating a hierarchy of bounding volumes , which is actually a binary tree with data only on leaf nodes. I implement it as a class, and not as a discriminated union, because the preservation of immutable elements is not an option to increase productivity, and discriminatory unions cannot have mutable members, only ref again, adding to Pressure in the Civil Code.
As stupid as in a functional language, I can just end each node type as an inheritance of the parent Node type. Downcasting is not the fastest operation, but with XNA and WP7, almost everything is better than defeating the GC.
source share