{"action":"created","issue":{"url":"https://api.github.com/repos/dotnet/csharplang/issues/1479","repository_url":"https://api.github.com/repos/dotnet/csharplang","labels_url":"https://api.github.com/repos/dotnet/csharplang/issues/1479/labels{/name}","comments_url":"https://api.github.com/repos/dotnet/csharplang/issues/1479/comments","events_url":"https://api.github.com/repos/dotnet/csharplang/issues/1479/events","html_url":"https://github.com/dotnet/csharplang/issues/1479","id":317382160,"number":1479,"title":"Proposal: Allow readonly ref structs to implement interfaces, but disallow boxing them","user":{"login":"ZacLiveEarth","id":15931232,"avatar_url":"https://avatars3.githubusercontent.com/u/15931232?v=4","gravatar_id":"","url":"https://api.github.com/users/ZacLiveEarth","html_url":"https://github.com/ZacLiveEarth","followers_url":"https://api.github.com/users/ZacLiveEarth/followers","following_url":"https://api.github.com/users/ZacLiveEarth/following{/other_user}","gists_url":"https://api.github.com/users/ZacLiveEarth/gists{/gist_id}","starred_url":"https://api.github.com/users/ZacLiveEarth/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ZacLiveEarth/subscriptions","organizations_url":"https://api.github.com/users/ZacLiveEarth/orgs","repos_url":"https://api.github.com/users/ZacLiveEarth/repos","events_url":"https://api.github.com/users/ZacLiveEarth/events{/privacy}","received_events_url":"https://api.github.com/users/ZacLiveEarth/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":6,"created_at":"2018-04-24T20:26:51Z","updated_at":"2018-04-24T22:50:23Z","closed_at":null,"author_association":"NONE","body":"I'm trying to implement a basic stack-based memory pool that returns Spans<T> to the user of the API. The basic API looks like this...\r\n\r\n`public static PoolToken Acquire(int length, out Span<T> span);`\r\n\r\n\r\nPoolToken is a struct which would like to implement IDisposable, where Dispose clears the span (if it contains types which have references) and returns the memory to the pool. So, the user can consume the API like so...\r\n\r\n`using(Acquire(length, out var span)) { /*Do things with span*/ }`\r\n\r\nBecause IDisposable is pattern based, and no boxing is required, this shouldn't violate any of the rules for Span and ref structs.\r\n\r\nThere may be some other uses for this beyond IDisposable. Other pattern-based code like foreach/IEnumerable may benefit, as may code using pattern matching with generic types like the BoxingAllocations example from [Performance Improvements in .Net Core 2.1](https://blogs.msdn.microsoft.com/dotnet/2018/04/18/performance-improvements-in-net-core-2-1/\r\n)\r\n\r\nPossibly related proposals: https://github.com/dotnet/csharplang/issues/93, https://github.com/dotnet/csharplang/issues/1148"},"comment":{"url":"https://api.github.com/repos/dotnet/csharplang/issues/comments/384104189","html_url":"https://github.com/dotnet/csharplang/issues/1479#issuecomment-384104189","issue_url":"https://api.github.com/repos/dotnet/csharplang/issues/1479","id":384104189,"user":{"login":"benaadams","id":1142958,"avatar_url":"https://avatars1.githubusercontent.com/u/1142958?v=4","gravatar_id":"","url":"https://api.github.com/users/benaadams","html_url":"https://github.com/benaadams","followers_url":"https://api.github.com/users/benaadams/followers","following_url":"https://api.github.com/users/benaadams/following{/other_user}","gists_url":"https://api.github.com/users/benaadams/gists{/gist_id}","starred_url":"https://api.github.com/users/benaadams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/benaadams/subscriptions","organizations_url":"https://api.github.com/users/benaadams/orgs","repos_url":"https://api.github.com/users/benaadams/repos","events_url":"https://api.github.com/users/benaadams/events{/privacy}","received_events_url":"https://api.github.com/users/benaadams/received_events","type":"User","site_admin":false},"created_at":"2018-04-24T22:50:23Z","updated_at":"2018-04-24T22:50:23Z","author_association":"NONE","body":"> > though can't current prevent it in the constrained method\r\n\r\n> Would you mind explaining this?\r\n```csharp\r\nvoid Method<T>(T value)\r\n    where T : IEquatable<T>\r\n{\r\n    // What prevents this?\r\n    object boxedValue = (object)value;\r\n}\r\n```"}}
{"actor":{"display_login":"benaadams"}}