{"action":"created","issue":{"url":"https://api.github.com/repos/hylang/hy/issues/1166","repository_url":"https://api.github.com/repos/hylang/hy","labels_url":"https://api.github.com/repos/hylang/hy/issues/1166/labels{/name}","comments_url":"https://api.github.com/repos/hylang/hy/issues/1166/comments","events_url":"https://api.github.com/repos/hylang/hy/issues/1166/events","html_url":"https://github.com/hylang/hy/pull/1166","id":194415900,"number":1166,"title":"Proper tail recursion","user":{"login":"Tritlo","id":1667287,"avatar_url":"https://avatars.githubusercontent.com/u/1667287?v=3","gravatar_id":"","url":"https://api.github.com/users/Tritlo","html_url":"https://github.com/Tritlo","followers_url":"https://api.github.com/users/Tritlo/followers","following_url":"https://api.github.com/users/Tritlo/following{/other_user}","gists_url":"https://api.github.com/users/Tritlo/gists{/gist_id}","starred_url":"https://api.github.com/users/Tritlo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Tritlo/subscriptions","organizations_url":"https://api.github.com/users/Tritlo/orgs","repos_url":"https://api.github.com/users/Tritlo/repos","events_url":"https://api.github.com/users/Tritlo/events{/privacy}","received_events_url":"https://api.github.com/users/Tritlo/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":15,"created_at":"2016-12-08T18:57:53Z","updated_at":"2016-12-10T12:31:37Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/hylang/hy/pulls/1166","html_url":"https://github.com/hylang/hy/pull/1166","diff_url":"https://github.com/hylang/hy/pull/1166.diff","patch_url":"https://github.com/hylang/hy/pull/1166.patch"},"body":"I merged and squashed the work I did in #728.\r\n\r\nI've added support for Proper tail recursion in Hy. It's optional, and can be enabled with an\r\n\r\n```\r\n(import [__future__ [TailRec]])\r\n```\r\n\r\nin the Hy source where it is needed. Benefits can be seen for example in the tests, where we can use _mutual recursive_ functions (not just self recurring, as the current loop macro implements) on much larger   values without hitting a recursion depth exceeded exception.\r\n\r\nThis is actually more powerful than loop, since it allows mutually recursive functions. I'm not sure that this can be moved into contrib, since we need access to the expressions themselves when we convert the return into an exception. This is needed to break out of the stack, and avoid a stack overflow. This also allows us to have tail recursive functions within other tail recursive functions, without any additional overhead.\r\n\r\nThe overhead can definitely slow this down, which is why we use the from future expression, to avoid the overhead where we can.\r\n"},"comment":{"url":"https://api.github.com/repos/hylang/hy/issues/comments/266204572","html_url":"https://github.com/hylang/hy/pull/1166#issuecomment-266204572","issue_url":"https://api.github.com/repos/hylang/hy/issues/1166","id":266204572,"user":{"login":"rwtolbert","id":283685,"avatar_url":"https://avatars.githubusercontent.com/u/283685?v=3","gravatar_id":"","url":"https://api.github.com/users/rwtolbert","html_url":"https://github.com/rwtolbert","followers_url":"https://api.github.com/users/rwtolbert/followers","following_url":"https://api.github.com/users/rwtolbert/following{/other_user}","gists_url":"https://api.github.com/users/rwtolbert/gists{/gist_id}","starred_url":"https://api.github.com/users/rwtolbert/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rwtolbert/subscriptions","organizations_url":"https://api.github.com/users/rwtolbert/orgs","repos_url":"https://api.github.com/users/rwtolbert/repos","events_url":"https://api.github.com/users/rwtolbert/events{/privacy}","received_events_url":"https://api.github.com/users/rwtolbert/received_events","type":"User","site_admin":false},"created_at":"2016-12-10T12:31:37Z","updated_at":"2016-12-10T12:31:37Z","body":"one simple question about using __future__.\r\n\r\nTo me the implication is that a feature imported from the future is intended to become native at some point. If this will always be an optional feature the programmer has to enable and never turned on by default, then I think a different import name should be used."}}
{"actor":{"display_login":"rwtolbert"}}