Skip to content
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

Closed
ygc369 opened this issue Apr 17, 2015 · 3 comments
Closed

Please allow class contain memory of other class or fixed size array #4143

ygc369 opened this issue Apr 17, 2015 · 3 comments

Comments

@ygc369
Copy link

ygc369 commented Apr 17, 2015

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"
};

@jkotas
Copy link
Member

jkotas commented Apr 17, 2015

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 jkotas closed this as completed Apr 17, 2015
@ygc369
Copy link
Author

ygc369 commented Apr 18, 2015

@jkotas
Thank you for your reply, I'm sorry for not looking at the ongoing design discussions on C# language design, but I think this issue shouldn't be closed. Though some of my ideas have been topic, others are not, such as using an existing class as struct. Please add my requests to design discussions on C# language design except those already tracked.
for example:
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
B[] b3; //a reference to a reference array
struct B[] b4; //a reference to an array which stores values directly
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"
int[] z; //normal array
};
mem
If these requests can be realized, C# can be as flexible as C/C++.

@kangaroo
Copy link
Contributor

@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 :)

@msftgits msftgits transferred this issue from dotnet/coreclr Jan 30, 2020
@ghost ghost locked as resolved and limited conversation to collaborators Jan 6, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants