{"action":"created","issue":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/10980","labels_url":"https://api.github.com/repos/JuliaLang/julia/issues/10980/labels{/name}","comments_url":"https://api.github.com/repos/JuliaLang/julia/issues/10980/comments","events_url":"https://api.github.com/repos/JuliaLang/julia/issues/10980/events","html_url":"https://github.com/JuliaLang/julia/issues/10980","id":70627618,"number":10980,"title":"Type stable block","user":{"login":"bpiwowar","id":423314,"avatar_url":"https://avatars.githubusercontent.com/u/423314?v=3","gravatar_id":"","url":"https://api.github.com/users/bpiwowar","html_url":"https://github.com/bpiwowar","followers_url":"https://api.github.com/users/bpiwowar/followers","following_url":"https://api.github.com/users/bpiwowar/following{/other_user}","gists_url":"https://api.github.com/users/bpiwowar/gists{/gist_id}","starred_url":"https://api.github.com/users/bpiwowar/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bpiwowar/subscriptions","organizations_url":"https://api.github.com/users/bpiwowar/orgs","repos_url":"https://api.github.com/users/bpiwowar/repos","events_url":"https://api.github.com/users/bpiwowar/events{/privacy}","received_events_url":"https://api.github.com/users/bpiwowar/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/JuliaLang/julia/labels/speculative","name":"speculative","color":"999999"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":24,"created_at":"2015-04-24T08:37:43Z","updated_at":"2015-06-06T17:29:49Z","closed_at":null,"body":"Given the importance of type stability, I would like to propose a new language construct that would allow semi-static checking of type stable blocks. In the module I am developing, I am frequently using this type of construct\r\n\r\n```julia\r\nfunction f(a)\r\n # Type stability\r\n@stabilize m::Matrix{Float64} = a.m\r\n\r\n # Compute things with m\r\n\r\nend\r\n...\r\n```\r\n\r\nI know there are:\r\n\r\n1. The possibility to use a function - but this can be cumbersome when there are many types, and in makes the code harder to read (at least for me)\r\n1. Tools like Lint or TypeCheck, and the macro `@code_warntype` that are useful to see/check whether the written code is type stable\r\n\r\nbut I would really like to have something that prevents code from being instable, e.g. using a \"stable block\" (I check and this gives a syntax error with julia 0.[34]):\r\n\r\n```julia\r\nfunction f(a)\r\n # Type stability\r\n@stabilize m::Matrix{Float64} = a.m\r\n\r\n stable begin\r\n  # Compute things - compilation error (or warning) if there is some type instability within the code\r\n end\r\n\r\nend\r\n...\r\n```\r\n\r\nAnother syntactic possibility would be to use pragmas #7449 (if they make it in the language)."},"comment":{"url":"https://api.github.com/repos/JuliaLang/julia/issues/comments/109620829","html_url":"https://github.com/JuliaLang/julia/issues/10980#issuecomment-109620829","issue_url":"https://api.github.com/repos/JuliaLang/julia/issues/10980","id":109620829,"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},"created_at":"2015-06-06T17:29:49Z","updated_at":"2015-06-06T17:29:49Z","body":"Yep, it's a bug. See discussion in #11595. You may just want to wait for it to be fixed before tackling this further, or you can locally back out the troublesome commit and then rebase when the fix arrives.\r\n\r\nThanks for looking into this!"}}