{"action":"created","issue":{"url":"https://api.github.com/repos/goldingn/gpe/issues/23","labels_url":"https://api.github.com/repos/goldingn/gpe/issues/23/labels{/name}","comments_url":"https://api.github.com/repos/goldingn/gpe/issues/23/comments","events_url":"https://api.github.com/repos/goldingn/gpe/issues/23/events","html_url":"https://github.com/goldingn/gpe/issues/23","id":59412815,"number":23,"title":"kernel and parameter objects don't clone their environments if copied","user":{"login":"goldingn","id":4450731,"avatar_url":"https://avatars.githubusercontent.com/u/4450731?v=3","gravatar_id":"","url":"https://api.github.com/users/goldingn","html_url":"https://github.com/goldingn","followers_url":"https://api.github.com/users/goldingn/followers","following_url":"https://api.github.com/users/goldingn/following{/other_user}","gists_url":"https://api.github.com/users/goldingn/gists{/gist_id}","starred_url":"https://api.github.com/users/goldingn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goldingn/subscriptions","organizations_url":"https://api.github.com/users/goldingn/orgs","repos_url":"https://api.github.com/users/goldingn/repos","events_url":"https://api.github.com/users/goldingn/events{/privacy}","received_events_url":"https://api.github.com/users/goldingn/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-03-01T19:16:03Z","updated_at":"2015-03-01T20:22:05Z","closed_at":null,"body":"So changing one changes the other, which is awful...\r\n\r\nkernel example:\r\n```r\r\nk1 <- rbf('a')\r\ngetParameters(k1)\r\n $sigma\r\n [1] 1\r\n\r\n $l\r\n [1] 1\r\n\r\nk2 <- k1\r\nk2 <- setParameters(k2, sigma = 2)\r\ngetParameters(k2)\r\n $sigma\r\n [1] 2\r\n\r\n $l\r\n [1] 1\r\n\r\ngetParameters(k1)\r\n $sigma\r\n [1] 2\r\n\r\n $l\r\n [1] 1\r\n```\r\n\r\nparameter example:\r\n```r\r\np <- pos(1)\r\np()\r\n [1] 1\r\nq <- p\r\nq <- update(q, 3)\r\nq()\r\n [1] 3\r\np()\r\n [1] 3\r\n```\r\n\r\nThis is undoubtedly due to messing about with their environments, but that's necessary for the executable objects, which I *really like*.\r\n\r\nPlan:\r\n1. define a clone function (for each of the two classes) which copies everything over into a new environment\r\n2. overload the assignment operators for these classes to clone rather than copy?"},"comment":{"url":"https://api.github.com/repos/goldingn/gpe/issues/comments/76628247","html_url":"https://github.com/goldingn/gpe/issues/23#issuecomment-76628247","issue_url":"https://api.github.com/repos/goldingn/gpe/issues/23","id":76628247,"user":{"login":"goldingn","id":4450731,"avatar_url":"https://avatars.githubusercontent.com/u/4450731?v=3","gravatar_id":"","url":"https://api.github.com/users/goldingn","html_url":"https://github.com/goldingn","followers_url":"https://api.github.com/users/goldingn/followers","following_url":"https://api.github.com/users/goldingn/following{/other_user}","gists_url":"https://api.github.com/users/goldingn/gists{/gist_id}","starred_url":"https://api.github.com/users/goldingn/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goldingn/subscriptions","organizations_url":"https://api.github.com/users/goldingn/orgs","repos_url":"https://api.github.com/users/goldingn/repos","events_url":"https://api.github.com/users/goldingn/events{/privacy}","received_events_url":"https://api.github.com/users/goldingn/received_events","type":"User","site_admin":false},"created_at":"2015-03-01T20:22:05Z","updated_at":"2015-03-01T20:22:05Z","body":"A plan:\r\n\r\nA demo function which returns it's own attributes as a list:\r\n```r\r\nfoo <- function (columns = NULL) {\r\n  object <- attributes(get(deparse(match.call()[[1]]),\r\n                        envir = parent.env(environment())))[-1]\r\n  return (object)\r\n}\r\nattributes(foo)$name <- 'queue'\r\nattributes(foo)$fun = log\r\nfoo()\r\n  $name\r\n  [1] \"queue\"\r\n\r\n  $fun\r\n  function (x, base = exp(1))  .Primitive(\"log\")\r\n```\r\n\r\nI had no luck trying to wrap that awful statement up in it's own function (lost in environments) but this should work in a kernel/parameter meta constructor"}}