{"action":"created","comment":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/comments/102570042","pull_request_review_id":23330095,"id":102570042,"diff_hunk":"@@ -215,13 +253,45 @@ Dict{String,Float64} with 3 entries:\n   \"foo\" => 0.0\n ```\n \"\"\"\n-function merge(d::Associative, others::Associative...)\n+merge(d::Associative, others::Associative...) =\n+    merge!(emptymergedict(d, others...), d, others...)\n+\n+\"\"\"\n+    merge(combine, d::Associative, others::Associative...)\n+\n+Construct a merged collection from the given collections. If necessary, the\n+types of the resulting collection will be promoted to accommodate the types of\n+the merged collections. Values with the same key will be combined using the\n+combiner function.\n+\n+```jldoctest\n+julia> a = Dict(\"foo\" => 0.0, \"bar\" => 42.0)\n+Dict{String,Float64} with 2 entries:\n+  \"bar\" => 42.0\n+  \"foo\" => 0.0\n+\n+julia> b = Dict(\"baz\" => 17, \"bar\" => 4711)\n+Dict{String,Int64} with 2 entries:\n+  \"bar\" => 4711\n+  \"baz\" => 17\n+\n+julia> merge(+, a, b)\n+Dict{String,Float64} with 3 entries:\n+  \"bar\" => 4753.0\n+  \"baz\" => 17.0\n+  \"foo\" => 0.0\n+```\n+\"\"\"\n+merge(combine::Function, d::Associative, others::Associative...) =\n+    merge!(combine, emptymergedict(d, others...), d, others...)\n+\n+function emptymergedict(d::Associative, others::Associative...)\n     K, V = keytype(d), valtype(d)","path":"base/associative.jl","position":83,"original_position":83,"commit_id":"8a45b3410685d3ffaf9359a431a1cd3f88910bbe","original_commit_id":"8a45b3410685d3ffaf9359a431a1cd3f88910bbe","user":{"login":"fredrikekre","id":11698744,"avatar_url":"https://avatars.githubusercontent.com/u/11698744?v=3","gravatar_id":"","url":"https://api.github.com/users/fredrikekre","html_url":"https://github.com/fredrikekre","followers_url":"https://api.github.com/users/fredrikekre/followers","following_url":"https://api.github.com/users/fredrikekre/following{/other_user}","gists_url":"https://api.github.com/users/fredrikekre/gists{/gist_id}","starred_url":"https://api.github.com/users/fredrikekre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fredrikekre/subscriptions","organizations_url":"https://api.github.com/users/fredrikekre/orgs","repos_url":"https://api.github.com/users/fredrikekre/repos","events_url":"https://api.github.com/users/fredrikekre/events{/privacy}","received_events_url":"https://api.github.com/users/fredrikekre/received_events","type":"User","site_admin":false},"body":"Alright. How can I test that it is type-inferrable? Benchmarks?","created_at":"2017-02-22T20:55:27Z","updated_at":"2017-02-22T20:55:27Z","html_url":"https://github.com/JuliaLang/julia/pull/20708#discussion_r102570042","pull_request_url":"https://api.github.com/repos/JuliaLang/julia/pulls/20708","_links":{"self":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/comments/102570042"},"html":{"href":"https://github.com/JuliaLang/julia/pull/20708#discussion_r102570042"},"pull_request":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/20708"}}},"pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/20708","id":107155567,"html_url":"https://github.com/JuliaLang/julia/pull/20708","diff_url":"https://github.com/JuliaLang/julia/pull/20708.diff","patch_url":"https://github.com/JuliaLang/julia/pull/20708.patch","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/20708","number":20708,"state":"open","locked":false,"title":"Dict merge(!) with combiner function","user":{"login":"fredrikekre","id":11698744,"avatar_url":"https://avatars.githubusercontent.com/u/11698744?v=3","gravatar_id":"","url":"https://api.github.com/users/fredrikekre","html_url":"https://github.com/fredrikekre","followers_url":"https://api.github.com/users/fredrikekre/followers","following_url":"https://api.github.com/users/fredrikekre/following{/other_user}","gists_url":"https://api.github.com/users/fredrikekre/gists{/gist_id}","starred_url":"https://api.github.com/users/fredrikekre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fredrikekre/subscriptions","organizations_url":"https://api.github.com/users/fredrikekre/orgs","repos_url":"https://api.github.com/users/fredrikekre/repos","events_url":"https://api.github.com/users/fredrikekre/events{/privacy}","received_events_url":"https://api.github.com/users/fredrikekre/received_events","type":"User","site_admin":false},"body":"Implements part A of https://github.com/JuliaLang/julia/issues/20699\r\n\r\nDid not find any tests for `merge(!)` without combiner function so I added that.\r\n\r\nA bit of code duplication though. Something like this:\r\n\r\n```diff\r\ndiff --git a/base/associative.jl b/base/associative.jl\r\n-function merge!(d::Associative, others::Associative...)\r\n-    for other in others\r\n-        for (k,v) in other\r\n-            d[k] = v\r\n-        end\r\n-    end\r\n-    return d\r\n-end\r\n+merge!(d::Associative, others::Associative...) = merge!((i, j)-> j, d, others...)\r\n```\r\n\r\n\r\ncould be applied but would result in a slower `merge!`. Thoughts?","created_at":"2017-02-21T10:15:48Z","updated_at":"2017-02-22T20:55:27Z","closed_at":null,"merged_at":null,"merge_commit_sha":"492489556aebea537c208fad4f1243ba3b7d77d8","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/JuliaLang/julia/pulls/20708/commits","review_comments_url":"https://api.github.com/repos/JuliaLang/julia/pulls/20708/comments","review_comment_url":"https://api.github.com/repos/JuliaLang/julia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/20708/comments","statuses_url":"https://api.github.com/repos/JuliaLang/julia/statuses/8a45b3410685d3ffaf9359a431a1cd3f88910bbe","head":{"label":"fredrikekre:fe/dict-merge","ref":"fe/dict-merge","sha":"8a45b3410685d3ffaf9359a431a1cd3f88910bbe","user":{"login":"fredrikekre","id":11698744,"avatar_url":"https://avatars.githubusercontent.com/u/11698744?v=3","gravatar_id":"","url":"https://api.github.com/users/fredrikekre","html_url":"https://github.com/fredrikekre","followers_url":"https://api.github.com/users/fredrikekre/followers","following_url":"https://api.github.com/users/fredrikekre/following{/other_user}","gists_url":"https://api.github.com/users/fredrikekre/gists{/gist_id}","starred_url":"https://api.github.com/users/fredrikekre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fredrikekre/subscriptions","organizations_url":"https://api.github.com/users/fredrikekre/orgs","repos_url":"https://api.github.com/users/fredrikekre/repos","events_url":"https://api.github.com/users/fredrikekre/events{/privacy}","received_events_url":"https://api.github.com/users/fredrikekre/received_events","type":"User","site_admin":false},"repo":{"id":66498328,"name":"julia","full_name":"fredrikekre/julia","owner":{"login":"fredrikekre","id":11698744,"avatar_url":"https://avatars.githubusercontent.com/u/11698744?v=3","gravatar_id":"","url":"https://api.github.com/users/fredrikekre","html_url":"https://github.com/fredrikekre","followers_url":"https://api.github.com/users/fredrikekre/followers","following_url":"https://api.github.com/users/fredrikekre/following{/other_user}","gists_url":"https://api.github.com/users/fredrikekre/gists{/gist_id}","starred_url":"https://api.github.com/users/fredrikekre/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fredrikekre/subscriptions","organizations_url":"https://api.github.com/users/fredrikekre/orgs","repos_url":"https://api.github.com/users/fredrikekre/repos","events_url":"https://api.github.com/users/fredrikekre/events{/privacy}","received_events_url":"https://api.github.com/users/fredrikekre/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fredrikekre/julia","description":"The Julia Language: A fresh approach to technical computing.","fork":true,"url":"https://api.github.com/repos/fredrikekre/julia","forks_url":"https://api.github.com/repos/fredrikekre/julia/forks","keys_url":"https://api.github.com/repos/fredrikekre/julia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fredrikekre/julia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fredrikekre/julia/teams","hooks_url":"https://api.github.com/repos/fredrikekre/julia/hooks","issue_events_url":"https://api.github.com/repos/fredrikekre/julia/issues/events{/number}","events_url":"https://api.github.com/repos/fredrikekre/julia/events","assignees_url":"https://api.github.com/repos/fredrikekre/julia/assignees{/user}","branches_url":"https://api.github.com/repos/fredrikekre/julia/branches{/branch}","tags_url":"https://api.github.com/repos/fredrikekre/julia/tags","blobs_url":"https://api.github.com/repos/fredrikekre/julia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fredrikekre/julia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fredrikekre/julia/git/refs{/sha}","trees_url":"https://api.github.com/repos/fredrikekre/julia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fredrikekre/julia/statuses/{sha}","languages_url":"https://api.github.com/repos/fredrikekre/julia/languages","stargazers_url":"https://api.github.com/repos/fredrikekre/julia/stargazers","contributors_url":"https://api.github.com/repos/fredrikekre/julia/contributors","subscribers_url":"https://api.github.com/repos/fredrikekre/julia/subscribers","subscription_url":"https://api.github.com/repos/fredrikekre/julia/subscription","commits_url":"https://api.github.com/repos/fredrikekre/julia/commits{/sha}","git_commits_url":"https://api.github.com/repos/fredrikekre/julia/git/commits{/sha}","comments_url":"https://api.github.com/repos/fredrikekre/julia/comments{/number}","issue_comment_url":"https://api.github.com/repos/fredrikekre/julia/issues/comments{/number}","contents_url":"https://api.github.com/repos/fredrikekre/julia/contents/{+path}","compare_url":"https://api.github.com/repos/fredrikekre/julia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fredrikekre/julia/merges","archive_url":"https://api.github.com/repos/fredrikekre/julia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fredrikekre/julia/downloads","issues_url":"https://api.github.com/repos/fredrikekre/julia/issues{/number}","pulls_url":"https://api.github.com/repos/fredrikekre/julia/pulls{/number}","milestones_url":"https://api.github.com/repos/fredrikekre/julia/milestones{/number}","notifications_url":"https://api.github.com/repos/fredrikekre/julia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fredrikekre/julia/labels{/name}","releases_url":"https://api.github.com/repos/fredrikekre/julia/releases{/id}","deployments_url":"https://api.github.com/repos/fredrikekre/julia/deployments","created_at":"2016-08-24T20:46:42Z","updated_at":"2016-08-24T20:46:51Z","pushed_at":"2017-02-22T07:23:11Z","git_url":"git://github.com/fredrikekre/julia.git","ssh_url":"git@github.com:fredrikekre/julia.git","clone_url":"https://github.com/fredrikekre/julia.git","svn_url":"https://github.com/fredrikekre/julia","homepage":"http://julialang.org/","size":108334,"stargazers_count":0,"watchers_count":0,"language":"Julia","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":0,"default_branch":"master"}},"base":{"label":"JuliaLang:master","ref":"master","sha":"e21caeef496402bfaba65ee9739424ac60aa2b0d","user":{"login":"JuliaLang","id":743164,"avatar_url":"https://avatars.githubusercontent.com/u/743164?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaLang","html_url":"https://github.com/JuliaLang","followers_url":"https://api.github.com/users/JuliaLang/followers","following_url":"https://api.github.com/users/JuliaLang/following{/other_user}","gists_url":"https://api.github.com/users/JuliaLang/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaLang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaLang/subscriptions","organizations_url":"https://api.github.com/users/JuliaLang/orgs","repos_url":"https://api.github.com/users/JuliaLang/repos","events_url":"https://api.github.com/users/JuliaLang/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaLang/received_events","type":"Organization","site_admin":false},"repo":{"id":1644196,"name":"julia","full_name":"JuliaLang/julia","owner":{"login":"JuliaLang","id":743164,"avatar_url":"https://avatars.githubusercontent.com/u/743164?v=3","gravatar_id":"","url":"https://api.github.com/users/JuliaLang","html_url":"https://github.com/JuliaLang","followers_url":"https://api.github.com/users/JuliaLang/followers","following_url":"https://api.github.com/users/JuliaLang/following{/other_user}","gists_url":"https://api.github.com/users/JuliaLang/gists{/gist_id}","starred_url":"https://api.github.com/users/JuliaLang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JuliaLang/subscriptions","organizations_url":"https://api.github.com/users/JuliaLang/orgs","repos_url":"https://api.github.com/users/JuliaLang/repos","events_url":"https://api.github.com/users/JuliaLang/events{/privacy}","received_events_url":"https://api.github.com/users/JuliaLang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/JuliaLang/julia","description":"The Julia Language: A fresh approach to technical computing.","fork":false,"url":"https://api.github.com/repos/JuliaLang/julia","forks_url":"https://api.github.com/repos/JuliaLang/julia/forks","keys_url":"https://api.github.com/repos/JuliaLang/julia/keys{/key_id}","collaborators_url":"https://api.github.com/repos/JuliaLang/julia/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/JuliaLang/julia/teams","hooks_url":"https://api.github.com/repos/JuliaLang/julia/hooks","issue_events_url":"https://api.github.com/repos/JuliaLang/julia/issues/events{/number}","events_url":"https://api.github.com/repos/JuliaLang/julia/events","assignees_url":"https://api.github.com/repos/JuliaLang/julia/assignees{/user}","branches_url":"https://api.github.com/repos/JuliaLang/julia/branches{/branch}","tags_url":"https://api.github.com/repos/JuliaLang/julia/tags","blobs_url":"https://api.github.com/repos/JuliaLang/julia/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/JuliaLang/julia/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/JuliaLang/julia/git/refs{/sha}","trees_url":"https://api.github.com/repos/JuliaLang/julia/git/trees{/sha}","statuses_url":"https://api.github.com/repos/JuliaLang/julia/statuses/{sha}","languages_url":"https://api.github.com/repos/JuliaLang/julia/languages","stargazers_url":"https://api.github.com/repos/JuliaLang/julia/stargazers","contributors_url":"https://api.github.com/repos/JuliaLang/julia/contributors","subscribers_url":"https://api.github.com/repos/JuliaLang/julia/subscribers","subscription_url":"https://api.github.com/repos/JuliaLang/julia/subscription","commits_url":"https://api.github.com/repos/JuliaLang/julia/commits{/sha}","git_commits_url":"https://api.github.com/repos/JuliaLang/julia/git/commits{/sha}","comments_url":"https://api.github.com/repos/JuliaLang/julia/comments{/number}","issue_comment_url":"https://api.github.com/repos/JuliaLang/julia/issues/comments{/number}","contents_url":"https://api.github.com/repos/JuliaLang/julia/contents/{+path}","compare_url":"https://api.github.com/repos/JuliaLang/julia/compare/{base}...{head}","merges_url":"https://api.github.com/repos/JuliaLang/julia/merges","archive_url":"https://api.github.com/repos/JuliaLang/julia/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/JuliaLang/julia/downloads","issues_url":"https://api.github.com/repos/JuliaLang/julia/issues{/number}","pulls_url":"https://api.github.com/repos/JuliaLang/julia/pulls{/number}","milestones_url":"https://api.github.com/repos/JuliaLang/julia/milestones{/number}","notifications_url":"https://api.github.com/repos/JuliaLang/julia/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/JuliaLang/julia/labels{/name}","releases_url":"https://api.github.com/repos/JuliaLang/julia/releases{/id}","deployments_url":"https://api.github.com/repos/JuliaLang/julia/deployments","created_at":"2011-04-21T07:01:50Z","updated_at":"2017-02-22T15:50:06Z","pushed_at":"2017-02-22T20:37:05Z","git_url":"git://github.com/JuliaLang/julia.git","ssh_url":"git@github.com:JuliaLang/julia.git","clone_url":"https://github.com/JuliaLang/julia.git","svn_url":"https://github.com/JuliaLang/julia","homepage":"http://julialang.org/","size":138911,"stargazers_count":8250,"watchers_count":8250,"language":"Julia","has_issues":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":1911,"mirror_url":null,"open_issues_count":2180,"forks":1911,"open_issues":2180,"watchers":8250,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/20708"},"html":{"href":"https://github.com/JuliaLang/julia/pull/20708"},"issue":{"href":"https://api.github.com/repos/JuliaLang/julia/issues/20708"},"comments":{"href":"https://api.github.com/repos/JuliaLang/julia/issues/20708/comments"},"review_comments":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/20708/comments"},"review_comment":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/20708/commits"},"statuses":{"href":"https://api.github.com/repos/JuliaLang/julia/statuses/8a45b3410685d3ffaf9359a431a1cd3f88910bbe"}}}}
{"actor":{"display_login":"fredrikekre"}}