-
Notifications
You must be signed in to change notification settings - Fork 4.8k
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
Please allow class contain memory of other class or fixed size array #4143
Comments
This is a bag of C# language feature requests. Similar feature requests have actually been topic of recent C# language design discussion - check https://github.com/dotnet/roslyn/labels/Design%20Notes, e.g. dotnet/roslyn#126 is exactly one of your ideas. I suggest that you look at the ongoing design discussions on C# language design, and open new feature requests for the individual ideas that are not tracked yet. I am going to close this issue because of it is not actionable here. (BTW: CLR allows you to do most of the above, though using unverifiable IL.) |
@jkotas |
@ygc369 Hi! So @jkotas isn't suggesting your issue shouldn't be addressed. He's (rightfully) pointing out its filed in the wrong place. This repository is for the runtime which already supports the type of features you want. You are asking for language extensions, so they should likely be filed in the roslyn repository and tracked by that team. This doesn't say the issue or ideas aren't good, simply that they're in the wrong place :) |
Thus, total object number can be less, and GC pressure can be lower, even accessing class fields can be faster because they can be directly located by accessing memory only once, not twice or more.
The class or array included in other class would act as struct, and can't be referenced.
For example, CLR should allow users to define class like this:
class A
{
class B { int x; char c; };
struct B b; // for example, use keyword "struct" to force class B to act as struct
B b0; // a reference to class B
B b1[10]; // reference array, the array itself is stored in class A, but b1[0]~b1[9] are only reference
struct B b2[10]; //b2[0]~b2[9] are not reference, they store all fields of class B
int y[20]; //instead of "unsafe fixed int y[20]", when access "y", the index should be checked, so there is no necessary to use the keyword "unsafe"
};
The text was updated successfully, but these errors were encountered: