{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/11456","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/11456/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/11456/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/11456/events","html_url":"https://github.com/JuliaLang/julia/pull/11456","id":81551111,"number":11456,"title":"don't force global binding resolution in compiled code","user":{"login":"JeffBezanson","id":744556,"avatar_url":"https://avatars.githubusercontent.com/u/744556?v=3","gravatar_id":"","url":"https://api.github.com/users/JeffBezanson","html_url":"https://github.com/JeffBezanson","followers_url":"https://api.github.com/users/JeffBezanson/followers","following_url":"https://api.github.com/users/JeffBezanson/following{/other_user}","gists_url":"https://api.github.com/users/JeffBezanson/gists{/gist_id}","starred_url":"https://api.github.com/users/JeffBezanson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JeffBezanson/subscriptions","organizations_url":"https://api.github.com/users/JeffBezanson/orgs","repos_url":"https://api.github.com/users/JeffBezanson/repos","events_url":"https://api.github.com/users/JeffBezanson/events{/privacy}","received_events_url":"https://api.github.com/users/JeffBezanson/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":30,"created_at":"2015-05-27T17:47:39Z","updated_at":"2015-07-04T15:54:14Z","closed_at":"2015-06-12T22:31:33Z","pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/11456","html_url":"https://github.com/JuliaLang/julia/pull/11456","diff_url":"https://github.com/JuliaLang/julia/pull/11456.diff","patch_url":"https://github.com/JuliaLang/julia/pull/11456.patch"},"body":"Fall back to run time lookup when compiled code needs to access a global that cannot be found yet.\r\nFixes #7864.\r\n\r\nThis has performance implications; the run time lookup is very slow. However this probably doesn't happen very often. We only hit this case if you try to run (and therefore compile) code that uses a global that is not available yet, for example:\r\n\r\n```\r\njulia> function f()\r\n         g()\r\n       end\r\nf (generic function with 1 method)\r\n\r\njulia> f()\r\nERROR: UndefVarError: g not defined\r\n in f at none:2\r\n\r\njulia> g() = 0\r\ng (generic function with 1 method)\r\n\r\njulia> f()\r\n0\r\n```\r\n\r\nHowever, `g` could have been provided by a package, and in that case we used to do something totally wrong. With this PR it works better, but `f()` will be really slow. I suspect this code pattern mostly happens at the prompt, but I'm not sure. I should load a bunch of packages and instrument how many times this happens. If necessary we can fix the performance by caching the result of jl_get_binding for each such global variable use."},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/118525529","html_url":"https://github.com/JuliaLang/julia/pull/11456#issuecomment-118525529","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/11456","id":118525529,"user":{"login":"yuyichao","id":712232,"avatar_url":"https://avatars.githubusercontent.com/u/712232?v=3","gravatar_id":"","url":"https://api.github.com/users/yuyichao","html_url":"https://github.com/yuyichao","followers_url":"https://api.github.com/users/yuyichao/followers","following_url":"https://api.github.com/users/yuyichao/following{/other_user}","gists_url":"https://api.github.com/users/yuyichao/gists{/gist_id}","starred_url":"https://api.github.com/users/yuyichao/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yuyichao/subscriptions","organizations_url":"https://api.github.com/users/yuyichao/orgs","repos_url":"https://api.github.com/users/yuyichao/repos","events_url":"https://api.github.com/users/yuyichao/events{/privacy}","received_events_url":"https://api.github.com/users/yuyichao/received_events","type":"User","site_admin":false},"created_at":"2015-07-04T15:54:14Z","updated_at":"2015-07-04T15:54:14Z","body":"@StefanKarpinski @JeffBezanson Sorry to bring this up again but this just come into my mind.\r\n\r\nSo the argument of keeping the current binding behavior is that we can override sth like `STDOUT` and make it take effect everywhere. I expect this behavior is not used in many places so how bad it would be to make these object a wrapper / ref of the real one and just mutate them?\r\n\r\ni.e. instead of writing `STDOUT = <new stream>`, do `STDOUT[] = <new stream>` instead.\r\n"}}