{"action":"closed","number":4225,"pull_request":{"url":"https://api.github.com/repos/dlang/phobos/pulls/4225","id":67286656,"html_url":"https://github.com/dlang/phobos/pull/4225","diff_url":"https://github.com/dlang/phobos/pull/4225.diff","patch_url":"https://github.com/dlang/phobos/pull/4225.patch","issue_url":"https://api.github.com/repos/dlang/phobos/issues/4225","number":4225,"state":"closed","locked":false,"title":"std.experimental.allocator: provide a @safe GC Allocator","user":{"login":"wilzbach","id":4370550,"avatar_url":"https://avatars.githubusercontent.com/u/4370550?v=3","gravatar_id":"","url":"https://api.github.com/users/wilzbach","html_url":"https://github.com/wilzbach","followers_url":"https://api.github.com/users/wilzbach/followers","following_url":"https://api.github.com/users/wilzbach/following{/other_user}","gists_url":"https://api.github.com/users/wilzbach/gists{/gist_id}","starred_url":"https://api.github.com/users/wilzbach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wilzbach/subscriptions","organizations_url":"https://api.github.com/users/wilzbach/orgs","repos_url":"https://api.github.com/users/wilzbach/repos","events_url":"https://api.github.com/users/wilzbach/events{/privacy}","received_events_url":"https://api.github.com/users/wilzbach/received_events","type":"User","site_admin":false},"body":"Resubmission of #4190 (seems like Github doesn't allow reopening after force-pushing the HEAD) - sorry for the annoyance.\r\n\r\nIn brief the problem is that most operations like allocating an array are `@safe` (and `nothrow`) within normal D Code, so when the `GCAllocator` is used it should allow `@safe` code too. See #4190 for more details and a writeup of different ideas how one could design a API with the GCAllocator.\r\n\r\nWhat happened so far:\r\n\r\n- In #4190 I tried to set `expand` and `reallocate` to `@trusted`\r\n   apart from the fact the `expand` can't be trusted, GCAllocator's `shared` instance is still problematic, so we most likely have to create a `GCSafeAllocator`\r\n- In #4213 I tried to provide constraints for `makeArray`, so that `new T[..]` will be used for the safe allocator \r\n\r\nHere I combine both approaches and provide a `GCSafeAllocator` that\r\n- stubs `expand` and `reallocate`\r\n- catches the exceptions of `GC.malloc` ([afaict](http://forum.dlang.org/post/vkpcqpabhlxxenrnnhrd@forum.dlang.org) it's okay to return a false value  on a failed allocation)\r\n- I proxy `makeArraySafe` to `makeArray`, s.t. I can set it to `@trusted` (`makeArray` does some pointer work)\r\n\r\nDisadvantages:\r\n- If someone wants to use this in his library, he needs to call `makeArraySafe`\r\n- I am not sure whether we can set `makeArray` to `@safe`\r\n- D allows to shrink and expand arrays in `@safe` - however this approach does forbid that\r\n- We would have to proxy `make` too \r\n\r\nSo as said - this approach is not perfect and your input is very welcome & feel free to propose your own ideas ;-)","created_at":"2016-04-21T02:14:43Z","updated_at":"2016-04-29T20:56:32Z","closed_at":"2016-04-29T20:56:32Z","merged_at":null,"merge_commit_sha":"90d04495b5b09b276bc9c8266408a41b430e7707","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/dlang/phobos/pulls/4225/commits","review_comments_url":"https://api.github.com/repos/dlang/phobos/pulls/4225/comments","review_comment_url":"https://api.github.com/repos/dlang/phobos/pulls/comments{/number}","comments_url":"https://api.github.com/repos/dlang/phobos/issues/4225/comments","statuses_url":"https://api.github.com/repos/dlang/phobos/statuses/4f11ab05ef0222b4557586b147badae2fd1893f0","head":{"label":"wilzbach:trusted_gc_allocator","ref":"trusted_gc_allocator","sha":"4f11ab05ef0222b4557586b147badae2fd1893f0","user":{"login":"wilzbach","id":4370550,"avatar_url":"https://avatars.githubusercontent.com/u/4370550?v=3","gravatar_id":"","url":"https://api.github.com/users/wilzbach","html_url":"https://github.com/wilzbach","followers_url":"https://api.github.com/users/wilzbach/followers","following_url":"https://api.github.com/users/wilzbach/following{/other_user}","gists_url":"https://api.github.com/users/wilzbach/gists{/gist_id}","starred_url":"https://api.github.com/users/wilzbach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wilzbach/subscriptions","organizations_url":"https://api.github.com/users/wilzbach/orgs","repos_url":"https://api.github.com/users/wilzbach/repos","events_url":"https://api.github.com/users/wilzbach/events{/privacy}","received_events_url":"https://api.github.com/users/wilzbach/received_events","type":"User","site_admin":false},"repo":{"id":52009651,"name":"phobos","full_name":"wilzbach/phobos","owner":{"login":"wilzbach","id":4370550,"avatar_url":"https://avatars.githubusercontent.com/u/4370550?v=3","gravatar_id":"","url":"https://api.github.com/users/wilzbach","html_url":"https://github.com/wilzbach","followers_url":"https://api.github.com/users/wilzbach/followers","following_url":"https://api.github.com/users/wilzbach/following{/other_user}","gists_url":"https://api.github.com/users/wilzbach/gists{/gist_id}","starred_url":"https://api.github.com/users/wilzbach/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wilzbach/subscriptions","organizations_url":"https://api.github.com/users/wilzbach/orgs","repos_url":"https://api.github.com/users/wilzbach/repos","events_url":"https://api.github.com/users/wilzbach/events{/privacy}","received_events_url":"https://api.github.com/users/wilzbach/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/wilzbach/phobos","description":"The standard library of the D programming language","fork":true,"url":"https://api.github.com/repos/wilzbach/phobos","forks_url":"https://api.github.com/repos/wilzbach/phobos/forks","keys_url":"https://api.github.com/repos/wilzbach/phobos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/wilzbach/phobos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/wilzbach/phobos/teams","hooks_url":"https://api.github.com/repos/wilzbach/phobos/hooks","issue_events_url":"https://api.github.com/repos/wilzbach/phobos/issues/events{/number}","events_url":"https://api.github.com/repos/wilzbach/phobos/events","assignees_url":"https://api.github.com/repos/wilzbach/phobos/assignees{/user}","branches_url":"https://api.github.com/repos/wilzbach/phobos/branches{/branch}","tags_url":"https://api.github.com/repos/wilzbach/phobos/tags","blobs_url":"https://api.github.com/repos/wilzbach/phobos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/wilzbach/phobos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/wilzbach/phobos/git/refs{/sha}","trees_url":"https://api.github.com/repos/wilzbach/phobos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/wilzbach/phobos/statuses/{sha}","languages_url":"https://api.github.com/repos/wilzbach/phobos/languages","stargazers_url":"https://api.github.com/repos/wilzbach/phobos/stargazers","contributors_url":"https://api.github.com/repos/wilzbach/phobos/contributors","subscribers_url":"https://api.github.com/repos/wilzbach/phobos/subscribers","subscription_url":"https://api.github.com/repos/wilzbach/phobos/subscription","commits_url":"https://api.github.com/repos/wilzbach/phobos/commits{/sha}","git_commits_url":"https://api.github.com/repos/wilzbach/phobos/git/commits{/sha}","comments_url":"https://api.github.com/repos/wilzbach/phobos/comments{/number}","issue_comment_url":"https://api.github.com/repos/wilzbach/phobos/issues/comments{/number}","contents_url":"https://api.github.com/repos/wilzbach/phobos/contents/{+path}","compare_url":"https://api.github.com/repos/wilzbach/phobos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/wilzbach/phobos/merges","archive_url":"https://api.github.com/repos/wilzbach/phobos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/wilzbach/phobos/downloads","issues_url":"https://api.github.com/repos/wilzbach/phobos/issues{/number}","pulls_url":"https://api.github.com/repos/wilzbach/phobos/pulls{/number}","milestones_url":"https://api.github.com/repos/wilzbach/phobos/milestones{/number}","notifications_url":"https://api.github.com/repos/wilzbach/phobos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/wilzbach/phobos/labels{/name}","releases_url":"https://api.github.com/repos/wilzbach/phobos/releases{/id}","deployments_url":"https://api.github.com/repos/wilzbach/phobos/deployments","created_at":"2016-02-18T13:38:55Z","updated_at":"2016-03-08T13:03:37Z","pushed_at":"2016-04-29T20:51:49Z","git_url":"git://github.com/wilzbach/phobos.git","ssh_url":"git@github.com:wilzbach/phobos.git","clone_url":"https://github.com/wilzbach/phobos.git","svn_url":"https://github.com/wilzbach/phobos","homepage":"dlang.org/phobos","size":48290,"stargazers_count":1,"watchers_count":1,"language":"D","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"dlang:master","ref":"master","sha":"a1020244e941f4775f814deeabeed363725c2ad0","user":{"login":"dlang","id":565913,"avatar_url":"https://avatars.githubusercontent.com/u/565913?v=3","gravatar_id":"","url":"https://api.github.com/users/dlang","html_url":"https://github.com/dlang","followers_url":"https://api.github.com/users/dlang/followers","following_url":"https://api.github.com/users/dlang/following{/other_user}","gists_url":"https://api.github.com/users/dlang/gists{/gist_id}","starred_url":"https://api.github.com/users/dlang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlang/subscriptions","organizations_url":"https://api.github.com/users/dlang/orgs","repos_url":"https://api.github.com/users/dlang/repos","events_url":"https://api.github.com/users/dlang/events{/privacy}","received_events_url":"https://api.github.com/users/dlang/received_events","type":"Organization","site_admin":false},"repo":{"id":1257084,"name":"phobos","full_name":"dlang/phobos","owner":{"login":"dlang","id":565913,"avatar_url":"https://avatars.githubusercontent.com/u/565913?v=3","gravatar_id":"","url":"https://api.github.com/users/dlang","html_url":"https://github.com/dlang","followers_url":"https://api.github.com/users/dlang/followers","following_url":"https://api.github.com/users/dlang/following{/other_user}","gists_url":"https://api.github.com/users/dlang/gists{/gist_id}","starred_url":"https://api.github.com/users/dlang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dlang/subscriptions","organizations_url":"https://api.github.com/users/dlang/orgs","repos_url":"https://api.github.com/users/dlang/repos","events_url":"https://api.github.com/users/dlang/events{/privacy}","received_events_url":"https://api.github.com/users/dlang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/dlang/phobos","description":"The standard library of the D programming language","fork":false,"url":"https://api.github.com/repos/dlang/phobos","forks_url":"https://api.github.com/repos/dlang/phobos/forks","keys_url":"https://api.github.com/repos/dlang/phobos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dlang/phobos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dlang/phobos/teams","hooks_url":"https://api.github.com/repos/dlang/phobos/hooks","issue_events_url":"https://api.github.com/repos/dlang/phobos/issues/events{/number}","events_url":"https://api.github.com/repos/dlang/phobos/events","assignees_url":"https://api.github.com/repos/dlang/phobos/assignees{/user}","branches_url":"https://api.github.com/repos/dlang/phobos/branches{/branch}","tags_url":"https://api.github.com/repos/dlang/phobos/tags","blobs_url":"https://api.github.com/repos/dlang/phobos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dlang/phobos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dlang/phobos/git/refs{/sha}","trees_url":"https://api.github.com/repos/dlang/phobos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dlang/phobos/statuses/{sha}","languages_url":"https://api.github.com/repos/dlang/phobos/languages","stargazers_url":"https://api.github.com/repos/dlang/phobos/stargazers","contributors_url":"https://api.github.com/repos/dlang/phobos/contributors","subscribers_url":"https://api.github.com/repos/dlang/phobos/subscribers","subscription_url":"https://api.github.com/repos/dlang/phobos/subscription","commits_url":"https://api.github.com/repos/dlang/phobos/commits{/sha}","git_commits_url":"https://api.github.com/repos/dlang/phobos/git/commits{/sha}","comments_url":"https://api.github.com/repos/dlang/phobos/comments{/number}","issue_comment_url":"https://api.github.com/repos/dlang/phobos/issues/comments{/number}","contents_url":"https://api.github.com/repos/dlang/phobos/contents/{+path}","compare_url":"https://api.github.com/repos/dlang/phobos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dlang/phobos/merges","archive_url":"https://api.github.com/repos/dlang/phobos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dlang/phobos/downloads","issues_url":"https://api.github.com/repos/dlang/phobos/issues{/number}","pulls_url":"https://api.github.com/repos/dlang/phobos/pulls{/number}","milestones_url":"https://api.github.com/repos/dlang/phobos/milestones{/number}","notifications_url":"https://api.github.com/repos/dlang/phobos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dlang/phobos/labels{/name}","releases_url":"https://api.github.com/repos/dlang/phobos/releases{/id}","deployments_url":"https://api.github.com/repos/dlang/phobos/deployments","created_at":"2011-01-15T07:00:06Z","updated_at":"2016-04-27T21:40:35Z","pushed_at":"2016-04-29T20:56:07Z","git_url":"git://github.com/dlang/phobos.git","ssh_url":"git@github.com:dlang/phobos.git","clone_url":"https://github.com/dlang/phobos.git","svn_url":"https://github.com/dlang/phobos","homepage":"dlang.org/phobos","size":76008,"stargazers_count":705,"watchers_count":705,"language":"D","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":478,"mirror_url":null,"open_issues_count":81,"forks":478,"open_issues":81,"watchers":705,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/dlang/phobos/pulls/4225"},"html":{"href":"https://github.com/dlang/phobos/pull/4225"},"issue":{"href":"https://api.github.com/repos/dlang/phobos/issues/4225"},"comments":{"href":"https://api.github.com/repos/dlang/phobos/issues/4225/comments"},"review_comments":{"href":"https://api.github.com/repos/dlang/phobos/pulls/4225/comments"},"review_comment":{"href":"https://api.github.com/repos/dlang/phobos/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/dlang/phobos/pulls/4225/commits"},"statuses":{"href":"https://api.github.com/repos/dlang/phobos/statuses/4f11ab05ef0222b4557586b147badae2fd1893f0"}},"merged":false,"mergeable":true,"mergeable_state":"unstable","merged_by":null,"comments":6,"review_comments":0,"commits":1,"additions":119,"deletions":0,"changed_files":1}}