{"action":"created","issue":{"url":"https://api.github.com/repos/jalvesaq/Nvim-R/issues/34","repository_url":"https://api.github.com/repos/jalvesaq/Nvim-R","labels_url":"https://api.github.com/repos/jalvesaq/Nvim-R/issues/34/labels{/name}","comments_url":"https://api.github.com/repos/jalvesaq/Nvim-R/issues/34/comments","events_url":"https://api.github.com/repos/jalvesaq/Nvim-R/issues/34/events","html_url":"https://github.com/jalvesaq/Nvim-R/issues/34","id":138176230,"number":34,"title":"load function does not correctly load nested function via : ,ff ","user":{"login":"zamaterian","id":282351,"avatar_url":"https://avatars.githubusercontent.com/u/282351?v=3","gravatar_id":"","url":"https://api.github.com/users/zamaterian","html_url":"https://github.com/zamaterian","followers_url":"https://api.github.com/users/zamaterian/followers","following_url":"https://api.github.com/users/zamaterian/following{/other_user}","gists_url":"https://api.github.com/users/zamaterian/gists{/gist_id}","starred_url":"https://api.github.com/users/zamaterian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zamaterian/subscriptions","organizations_url":"https://api.github.com/users/zamaterian/orgs","repos_url":"https://api.github.com/users/zamaterian/repos","events_url":"https://api.github.com/users/zamaterian/events{/privacy}","received_events_url":"https://api.github.com/users/zamaterian/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":3,"created_at":"2016-03-03T13:21:08Z","updated_at":"2016-03-03T14:09:12Z","closed_at":null,"body":"Load nested functions dosn't include the outer function.\r\n\r\nCheers\r\n\r\n\r\n \r\n\r\ngetInParentsFrame  <-  function(name){\r\n    # recursing through parent frames looking for name\r\n    sysf  <- rev(sys.parents())\r\n    ff  <-  function(sysf){\r\n        n  <-  head(sysf,1)\r\n        if (length(sysf) == 0)\r\n        {\r\n            return (\"\")\r\n        }\r\n# CURSOR HERE \r\n        env  <-  sys.frame(n)\r\n        if (identical(env, emptyenv()))\r\n        {\r\n            return (\"\")\r\n        }\r\n        else if (exists(name, envir = env, inherits = FALSE))\r\n        {\r\n            get(name,envir=env)\r\n        }\r\n        else\r\n        {\r\n            ff(tail(sysf,-1))\r\n        }}\r\n    ff(sysf)\r\n}\r\nresults in  the tmp file\t\t\t:\r\n\r\ncat /tmp/Nvim-R-te/Rsource-11287 \r\n\r\n    ff  <-  function(sysf){\r\n        n  <-  head(sysf,1)\r\n        if (length(sysf) == 0)\r\n        {\r\n            return (\"\")\r\n        }\r\n\r\n        env  <-  sys.frame(n)\r\n        if (identical(env, emptyenv()))\r\n        {\r\n            return (\"\")\r\n        }\r\n        else if (exists(name, envir = env, inherits = FALSE))\r\n        {\r\n            get(name,envir=env)\r\n        }\r\n        else\r\n        {\r\n            ff(tail(sysf,-1))\r\n        }}\r\n \r\n\r\n"},"comment":{"url":"https://api.github.com/repos/jalvesaq/Nvim-R/issues/comments/191777379","html_url":"https://github.com/jalvesaq/Nvim-R/issues/34#issuecomment-191777379","issue_url":"https://api.github.com/repos/jalvesaq/Nvim-R/issues/34","id":191777379,"user":{"login":"zamaterian","id":282351,"avatar_url":"https://avatars.githubusercontent.com/u/282351?v=3","gravatar_id":"","url":"https://api.github.com/users/zamaterian","html_url":"https://github.com/zamaterian","followers_url":"https://api.github.com/users/zamaterian/followers","following_url":"https://api.github.com/users/zamaterian/following{/other_user}","gists_url":"https://api.github.com/users/zamaterian/gists{/gist_id}","starred_url":"https://api.github.com/users/zamaterian/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/zamaterian/subscriptions","organizations_url":"https://api.github.com/users/zamaterian/orgs","repos_url":"https://api.github.com/users/zamaterian/repos","events_url":"https://api.github.com/users/zamaterian/events{/privacy}","received_events_url":"https://api.github.com/users/zamaterian/received_events","type":"User","site_admin":false},"created_at":"2016-03-03T14:09:12Z","updated_at":"2016-03-03T14:09:12Z","body":"Correct, but since the inner function is part of the lexical scope for the outer function, then the inner function should only be reload in context of the outer function. Not in the global scope.\r\n\r\nA similar case is when you have a tryCatch function, where you have defined error, warning, interrupt function. You need to move to the outer function outside of the tryCatch to reload/ otherwise you get an compile error.  \r\n"}}