{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/12292","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/12292/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/12292/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/12292/events","html_url":"https://github.com/JuliaLang/julia/pull/12292","id":96957776,"number":12292,"title":"Use inference to determine types in array operations","user":{"login":"timholy","id":1525481,"avatar_url":"https://avatars.githubusercontent.com/u/1525481?v=3","gravatar_id":"","url":"https://api.github.com/users/timholy","html_url":"https://github.com/timholy","followers_url":"https://api.github.com/users/timholy/followers","following_url":"https://api.github.com/users/timholy/following{/other_user}","gists_url":"https://api.github.com/users/timholy/gists{/gist_id}","starred_url":"https://api.github.com/users/timholy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/timholy/subscriptions","organizations_url":"https://api.github.com/users/timholy/orgs","repos_url":"https://api.github.com/users/timholy/repos","events_url":"https://api.github.com/users/timholy/events{/privacy}","received_events_url":"https://api.github.com/users/timholy/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":29,"created_at":"2015-07-24T03:54:29Z","updated_at":"2015-07-24T15:30:51Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/12292","html_url":"https://github.com/JuliaLang/julia/pull/12292","diff_url":"https://github.com/JuliaLang/julia/pull/12292.diff","patch_url":"https://github.com/JuliaLang/julia/pull/12292.patch"},"body":"This fixes the long-standing #8027, providing much better generic fallbacks for elementwise operations involving arrays and array/scalar operations. The proximal motivation for tackling this was to fix the ambiguity warnings triggered by #12115, but this will also (given suitable type-stability improvements to SIUnits) finally allow `eltype([1Meter]+1Meter) == typeof(1Meter)` and `eltype([1Meter]*(1Meter)) == typeof(1Meter^2)`. In some ways this turns out to be the (much easier) companion of #10525, defining operations that involve arrays in terms of operations defined for scalars. I think it will allow cleanup of a certain amount of torturous code.\r\n\r\nI had forgotten why we had `promote_array_type`; to save any reviewers the trouble, it turns out to be because we've decided that `eltype([1.0f0]+1.0) == Float32` (i.e., the eltype of the Array wins, when working with `Real` numbers). This rule obviously doesn't work for more generic types, but the exception does make sense so I've kept it.\r\n\r\nIf this meets with approval, I'll see about applying it to #12115.\r\n"},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/124559513","html_url":"https://github.com/JuliaLang/julia/pull/12292#issuecomment-124559513","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/12292","id":124559513,"user":{"login":"mbauman","id":154641,"avatar_url":"https://avatars.githubusercontent.com/u/154641?v=3","gravatar_id":"","url":"https://api.github.com/users/mbauman","html_url":"https://github.com/mbauman","followers_url":"https://api.github.com/users/mbauman/followers","following_url":"https://api.github.com/users/mbauman/following{/other_user}","gists_url":"https://api.github.com/users/mbauman/gists{/gist_id}","starred_url":"https://api.github.com/users/mbauman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mbauman/subscriptions","organizations_url":"https://api.github.com/users/mbauman/orgs","repos_url":"https://api.github.com/users/mbauman/repos","events_url":"https://api.github.com/users/mbauman/events{/privacy}","received_events_url":"https://api.github.com/users/mbauman/received_events","type":"User","site_admin":false},"created_at":"2015-07-24T15:30:51Z","updated_at":"2015-07-24T15:30:51Z","body":"Oh man, I'd love to see this solved.\r\n\r\nI think that the major downside to using `map`'s solution is that it extends the empty map problem to arithmetic (what is `Int[] + 1.0`?)… which (at least currently) would make arithmetic type-unstable."}}