{"action":"created","comment":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/comments/155603625","pull_request_review_id":81950796,"id":155603625,"diff_hunk":"@@ -29,14 +29,9 @@ similar(s::Set{T}) where {T} = Set{T}()\n similar(s::Set, T::Type) = Set{T}()\n \n function show(io::IO, s::Set)\n-    print(io, \"Set\")\n-    if isempty(s)\n-        print(io, \"{\", eltype(s), \"}()\")\n-        return\n-    end\n-    print(io, \"(\")\n-    show_vector(io, s, \"[\", \"]\")\n-    print(io, \")\")\n+    print(io, \"Set(\")\n+    show_vector(io, s)","path":"base/set.jl","position":13,"original_position":13,"commit_id":"76b83f01f05acbab9d767ac30445283033e19611","original_commit_id":"76b83f01f05acbab9d767ac30445283033e19611","user":{"login":"rfourquet","id":8462914,"avatar_url":"https://avatars1.githubusercontent.com/u/8462914?v=4","gravatar_id":"","url":"https://api.github.com/users/rfourquet","html_url":"https://github.com/rfourquet","followers_url":"https://api.github.com/users/rfourquet/followers","following_url":"https://api.github.com/users/rfourquet/following{/other_user}","gists_url":"https://api.github.com/users/rfourquet/gists{/gist_id}","starred_url":"https://api.github.com/users/rfourquet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rfourquet/subscriptions","organizations_url":"https://api.github.com/users/rfourquet/orgs","repos_url":"https://api.github.com/users/rfourquet/repos","events_url":"https://api.github.com/users/rfourquet/events{/privacy}","received_events_url":"https://api.github.com/users/rfourquet/received_events","type":"User","site_admin":false},"body":"I'm not good at naming, and I forged them on top of what was existing, but the `print_array` work for any array, while `show_vector` is a special method implemented only for 1-D collections, which is meant (as this example show) to be used beyond the array case. I just didn't change the original name for this one, and I can't think of a clearly better one.","created_at":"2017-12-07T18:33:30Z","updated_at":"2017-12-07T18:33:30Z","html_url":"https://github.com/JuliaLang/julia/pull/24651#discussion_r155603625","pull_request_url":"https://api.github.com/repos/JuliaLang/julia/pulls/24651","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/comments/155603625"},"html":{"href":"https://github.com/JuliaLang/julia/pull/24651#discussion_r155603625"},"pull_request":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/24651"}},"in_reply_to_id":155590495},"pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/24651","id":153502463,"html_url":"https://github.com/JuliaLang/julia/pull/24651","diff_url":"https://github.com/JuliaLang/julia/pull/24651.diff","patch_url":"https://github.com/JuliaLang/julia/pull/24651.patch","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/24651","number":24651,"state":"open","locked":false,"title":"IOContext: introduce the :typeinfo property","user":{"login":"rfourquet","id":8462914,"avatar_url":"https://avatars1.githubusercontent.com/u/8462914?v=4","gravatar_id":"","url":"https://api.github.com/users/rfourquet","html_url":"https://github.com/rfourquet","followers_url":"https://api.github.com/users/rfourquet/followers","following_url":"https://api.github.com/users/rfourquet/following{/other_user}","gists_url":"https://api.github.com/users/rfourquet/gists{/gist_id}","starred_url":"https://api.github.com/users/rfourquet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rfourquet/subscriptions","organizations_url":"https://api.github.com/users/rfourquet/orgs","repos_url":"https://api.github.com/users/rfourquet/repos","events_url":"https://api.github.com/users/rfourquet/events{/privacy}","received_events_url":"https://api.github.com/users/rfourquet/received_events","type":"User","site_admin":false},"body":"Before, the `:compact` property was conflating 2 concepts:\r\n1) are we low on screen space?\r\n2) can we skip printing individual type information for elements in a collection?\r\n\r\nCf. #22981 for context and discussion. Credit to Stefan Karpinski for the\r\nformulation of the design implemented here.\r\n\r\n</end commit message>\r\n\r\nSo this tackle only the redundancy in type information, not the number of digits of array elements to print (refered to as `:sigdigits` in the linked PR).\r\nHere is a short demo:\r\n```julia\r\njulia> a = rand(Float16, 2) # BEFORE:\r\n2-element Array{Float16,1}:\r\n Float16(0.1699)\r\n Float16(0.127)\r\n\r\njulia> show(a)\r\nFloat16[0.16992, 0.12695] # why the need to print more digits here?\r\n\r\njulia> reshape(a, 1, 1, 2)\r\n1×1×2 Array{Float16,3}:\r\n[:, :, 1] =\r\n Float16(0.1699)\r\n\r\n[:, :, 2] =\r\n Float16(0.127)\r\n\r\njulia> a = rand(Float16, 2) # AFTER\r\n2-element Array{Float16,1}:\r\n 0.1699\r\n 0.127\r\n\r\njulia> show(a)\r\nFloat16[0.1699, 0.127]\r\n\r\njulia> reshape(a, 1, 1, 2)\r\n1×1×2 Array{Float16,3}:\r\n[:, :, 1] =\r\n 0.1699\r\n\r\n[:, :, 2] =\r\n 0.127\r\n\r\njulia> show(ModInt[ModInt{3}(2), ModInt{4}(2)])  # BEFORE\r\nMain.ModInts.ModInt[2, 2]     # ouch, not quite unambiguous\r\n\r\njulia> [ModInt{3}(2)]  # but quite redundant here\r\n1-element Array{Main.ModInts.ModInt{3},1}:\r\n 2 mod 3\r\n\r\njulia> show(ModInt[ModInt{3}(2), ModInt{4}(2)]) # AFTER\r\nMain.ModInts.ModInt[2 mod 3, 2 mod 4]\r\n\r\njulia> [ModInt{3}(2)]\r\n1-element Array{Main.ModInts.ModInt{3},1}:\r\n 2\r\n\r\njulia> [Set([Set([Float16(1)])])]  # just because I can! # BEFORE\r\n1-element Array{Set{Set{Float16}},1}:\r\n Set(Set{Float16}[Set(Float16[1.0])])\r\n\r\njulia> [Set([Set([Float16(1)])])] # AFTER\r\n1-element Array{Set{Set{Float16}},1}:\r\n Set([Set([1.0])])\r\n``` \r\n\r\nI didn't update here the `show` method for every object which could take advantage of this new attribute, but this can be done incrementally.\r\n\r\nAlso, as my editor (emacs) had trouble indenting the \"show.jl\" file because it's too big, editing this file was a nightmare, so I put the method related to showing arrays in a new file, \"arrayshow.jl\", which I believe is a better organization anyway, regardless of my editing comfort. The code was quite entangled, with non-consistent function names, so I had also to refactor to have a chance to understand the interaction between the functions and to include the new feature (I'm fine of course with suggestions for naming).\r\n\r\nThe main refactoring change is that I deleted the labyrinthic `showarray` method, which had 2 options: `repr` and `header`. By tracing how it was called in base, it appeared that basically 2 independant code paths were used depending on the combination of those 2 options, so the most sane action was to split it into 2 distinct methods, which implement `show` and `display`. The result is a bit less powerful (not possible to call `showarray(io, X, false, header=false)`, but in the case were this was needed in base (for printing invalid strings), this was equivalent to `print_array(io, X)` (which doesn't know about `:typeinfo`, but this is fine for `UInt8` elements).\r\n\r\nTODO:\r\n- [X] write basic documentation to `IOContext`'s docstring (but there are already some explanatory comments in the new file)\r\n- [X] tests\r\n- [x] remove TODO in the commit message\r\n- [x] remove duplicated `alignment` in the first commit","created_at":"2017-11-19T15:57:46Z","updated_at":"2017-12-07T18:33:30Z","closed_at":null,"merged_at":null,"merge_commit_sha":"dc26c06d7ddbb9e944fa2de563381cb51a10782f","assignee":null,"assignees":[],"requested_reviewers":[],"milestone":null,"commits_url":"https://api.github.com/repos/JuliaLang/julia/pulls/24651/commits","review_comments_url":"https://api.github.com/repos/JuliaLang/julia/pulls/24651/comments","review_comment_url":"https://api.github.com/repos/JuliaLang/julia/pulls/comments{/number}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/24651/comments","statuses_url":"https://api.github.com/repos/JuliaLang/julia/statuses/76b83f01f05acbab9d767ac30445283033e19611","head":{"label":"JuliaLang:rf/typeinfo","ref":"rf/typeinfo","sha":"76b83f01f05acbab9d767ac30445283033e19611","user":{"login":"JuliaLang","id":743164,"avatar_url":"https://avatars0.githubusercontent.com/u/743164?v=4","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://avatars0.githubusercontent.com/u/743164?v=4","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-12-07T17:23:00Z","pushed_at":"2017-12-07T18:24:21Z","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":"https://julialang.org/","size":295519,"stargazers_count":9621,"watchers_count":9621,"language":"Julia","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":2187,"mirror_url":null,"archived":false,"open_issues_count":2424,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":2187,"open_issues":2424,"watchers":9621,"default_branch":"master"}},"base":{"label":"JuliaLang:master","ref":"master","sha":"2cde54b0502083f66978a0ae228fe461a3519c61","user":{"login":"JuliaLang","id":743164,"avatar_url":"https://avatars0.githubusercontent.com/u/743164?v=4","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://avatars0.githubusercontent.com/u/743164?v=4","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-12-07T17:23:00Z","pushed_at":"2017-12-07T18:24:21Z","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":"https://julialang.org/","size":295519,"stargazers_count":9621,"watchers_count":9621,"language":"Julia","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":true,"forks_count":2187,"mirror_url":null,"archived":false,"open_issues_count":2424,"license":{"key":"other","name":"Other","spdx_id":null,"url":null},"forks":2187,"open_issues":2424,"watchers":9621,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/24651"},"html":{"href":"https://github.com/JuliaLang/julia/pull/24651"},"issue":{"href":"https://api.github.com/repos/JuliaLang/julia/issues/24651"},"comments":{"href":"https://api.github.com/repos/JuliaLang/julia/issues/24651/comments"},"review_comments":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/24651/comments"},"review_comment":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/JuliaLang/julia/pulls/24651/commits"},"statuses":{"href":"https://api.github.com/repos/JuliaLang/julia/statuses/76b83f01f05acbab9d767ac30445283033e19611"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"rfourquet"}}