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 make weak reference a language feature instead of class #2171

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

Please make weak reference a language feature instead of class #2171

ygc369 opened this issue Apr 22, 2015 · 3 comments

Comments

@ygc369
Copy link

ygc369 commented Apr 22, 2015

I have committed this issue in coreclr repo, but they told me to commit here. https://github.com/dotnet/coreclr/issues/756
Current weak reference is class, when we use it, we must alloc slots from short or long weak reference table. Thus we can't use too many weak references. But I think this is not necessary. When GC happens, CLR can update strong references of living objects after compaction, why not update weak references of freed objects to be null at the same time? So weak reference can be a language feature instead of class, for example, use keyword "weakref" to specify a variable to store weak reference of an object.
Example:
Class A
{
weakref int[] a;
weakref object b;
};

@JohnnyBravo75
Copy link

I vote for this.
Here is another thrad that deals with weak events and weak references.
#101

@ygc369
Copy link
Author

ygc369 commented Oct 16, 2015

Apple's Swift language has this feature.

@gafter
Copy link
Member

gafter commented Mar 20, 2017

We are now taking language feature discussion on https://github.com/dotnet/csharplang for C# specific issues, https://github.com/dotnet/vblang for VB-specific features, and https://github.com/dotnet/csharplang for features that affect both languages.

@gafter gafter closed this as completed Mar 20, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants