{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/12491","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/12491/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/12491/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/12491/events","html_url":"https://github.com/JuliaLang/julia/pull/12491","id":99460067,"number":12491,"title":"compilethis(iscompilable) function for automated opt-in to module compilation","user":{"login":"stevengj","id":2913679,"avatar_url":"https://avatars.githubusercontent.com/u/2913679?v=3","gravatar_id":"","url":"https://api.github.com/users/stevengj","html_url":"https://github.com/stevengj","followers_url":"https://api.github.com/users/stevengj/followers","following_url":"https://api.github.com/users/stevengj/following{/other_user}","gists_url":"https://api.github.com/users/stevengj/gists{/gist_id}","starred_url":"https://api.github.com/users/stevengj/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stevengj/subscriptions","organizations_url":"https://api.github.com/users/stevengj/orgs","repos_url":"https://api.github.com/users/stevengj/repos","events_url":"https://api.github.com/users/stevengj/events{/privacy}","received_events_url":"https://api.github.com/users/stevengj/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/JuliaLang/julia/labels/precompile","name":"precompile","color":"fad8c7"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":19,"created_at":"2015-08-06T15:14:54Z","updated_at":"2015-08-06T17:09:30Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/JuliaLang/julia/pulls/12491","html_url":"https://github.com/JuliaLang/julia/pull/12491","diff_url":"https://github.com/JuliaLang/julia/pull/12491.diff","patch_url":"https://github.com/JuliaLang/julia/pull/12491.patch"},"body":"This addresses #12462 by adding a new function `compilethis(iscompilable::Bool=true)`:\r\n\r\n* If a file calls `compilethis()` (typically at the top of the file before the `module` statement), then it will be automatically compiled when it is imported for the first time (and thereafter will be automatically recompiled thanks to #12458).  Technically, `compilethis(true)` throws an exception if the file is included in a non-compile Julia process.\r\n\r\n* If a file calls `compilethis(false)`, then it will throw an exception during compilation.  This way, if a module is known to be unsafe to compile, you can prevent the user from compiling it accidentally (e.g. by importing it into another module that is being compiled).\r\n\r\n* Backwards compatibility with 0.3 is easy: just use `VERSION >= v\"0.4-\" && compilethis()`.  We should also put `compilethis` into Compat for completness, but it is nice to be able to put `compilethis()` *before* the `module ... end` in order to prevent the module from being parsed or evalled (even partially) when we are detecting compilability.\r\n\r\nThanks to @ScottPJones for his suggestion.  This turned out to be much cleaner than the `#pragma` approach in #12475, with no loss of functionality."},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/128446298","html_url":"https://github.com/JuliaLang/julia/pull/12491#issuecomment-128446298","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/12491","id":128446298,"user":{"login":"ScottPJones","id":11798751,"avatar_url":"https://avatars.githubusercontent.com/u/11798751?v=3","gravatar_id":"","url":"https://api.github.com/users/ScottPJones","html_url":"https://github.com/ScottPJones","followers_url":"https://api.github.com/users/ScottPJones/followers","following_url":"https://api.github.com/users/ScottPJones/following{/other_user}","gists_url":"https://api.github.com/users/ScottPJones/gists{/gist_id}","starred_url":"https://api.github.com/users/ScottPJones/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ScottPJones/subscriptions","organizations_url":"https://api.github.com/users/ScottPJones/orgs","repos_url":"https://api.github.com/users/ScottPJones/repos","events_url":"https://api.github.com/users/ScottPJones/events{/privacy}","received_events_url":"https://api.github.com/users/ScottPJones/received_events","type":"User","site_admin":false},"created_at":"2015-08-06T17:09:30Z","updated_at":"2015-08-06T17:09:30Z","body":"I think that they already know it is compiling the code, and in fact, `__compile__(true)` seems backwards, because what it means is you want to use that cache *instead* of always compiling the code.\r\n"}}