{"action":"created","issue":{"url":"https://api.github.com/repos/HenrikBengtsson/future/issues/58","repository_url":"https://api.github.com/repos/HenrikBengtsson/future","labels_url":"https://api.github.com/repos/HenrikBengtsson/future/issues/58/labels{/name}","comments_url":"https://api.github.com/repos/HenrikBengtsson/future/issues/58/comments","events_url":"https://api.github.com/repos/HenrikBengtsson/future/issues/58/events","html_url":"https://github.com/HenrikBengtsson/future/issues/58","id":137667725,"number":58,"title":"Future assignment operator: `%<=%`, `%<-%`, `:=`, ...?","user":{"login":"HenrikBengtsson","id":1616850,"avatar_url":"https://avatars.githubusercontent.com/u/1616850?v=3","gravatar_id":"","url":"https://api.github.com/users/HenrikBengtsson","html_url":"https://github.com/HenrikBengtsson","followers_url":"https://api.github.com/users/HenrikBengtsson/followers","following_url":"https://api.github.com/users/HenrikBengtsson/following{/other_user}","gists_url":"https://api.github.com/users/HenrikBengtsson/gists{/gist_id}","starred_url":"https://api.github.com/users/HenrikBengtsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HenrikBengtsson/subscriptions","organizations_url":"https://api.github.com/users/HenrikBengtsson/orgs","repos_url":"https://api.github.com/users/HenrikBengtsson/repos","events_url":"https://api.github.com/users/HenrikBengtsson/events{/privacy}","received_events_url":"https://api.github.com/users/HenrikBengtsson/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/HenrikBengtsson/future/labels/question","name":"question","color":"cc317c"}],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-03-01T19:45:07Z","updated_at":"2016-04-02T21:05:13Z","closed_at":"2016-04-02T21:05:13Z","body":"The future package is currently using `%<=%` for future assignments, e.g.\r\n```r\r\nx %<=% { Sys.getpid() }\r\n```\r\nBTW, the `=` symbol part of `%<=%` should be seen as two parallel lines suggesting _parallel processing_.\r\n\r\nI can see a few alternatives for future assignments, e.g.\r\n\r\n* `x %<=% { expr }`\r\n* `x %<-% { expr }`\r\n* `x %=% { expr }`\r\n* `x := { expr }`\r\n\r\nI'm leaving this issue here to keep notes on this and for others to pitch in.\r\n\r\n# Summary of pros and cons\r\nAn advantage with `%<-%` is that it is syntactically similar to the regular assignment operator `<-` in R.\r\n\r\nAn advantage with `%=%` is that it is syntactically similar to the assignment operator `=` in R that is also used in other languages.  It also resembles the \"parallel symbol\" through two parallel lines.\r\n\r\nAn advantage with any `%...%` infix operator is that it can be \"extended\", e.g. `%<=[memoize]%` (not saying it is a good thing to do, but at least it's possible).\r\n\r\nA disadvantage with any `%...%` operator is that it has higher precedence than several other operators, e.g.\r\n```r\r\n> x %<=% 2 * runif(1)\r\nError in x %<=% 2 * runif(1) : non-numeric argument to binary operator\r\n``` \r\nwhich means we need to put the future expression within brackets, i.e.\r\n```r\r\n> x %<=% { 2 * runif(1) }\r\n```\r\n\r\nAn advantage with the `:=` operator is that it does not have this problem and we could use:\r\n```r\r\n> x := 2 * runif(1)\r\n```\r\nProof of concept:\r\n```r\r\n> `:=` <- function(name, value) { list(name=substitute(name), value=substitute(value)) }\r\n> x := 2 * runif(1)\r\n$name\r\nx\r\n\r\n$value\r\n2 * runif(1)\r\n```\r\nThe disadvantage of `:=` is that it has higher precedence than `%...%`, which probably will break for instance `%plan%`, e.g.\r\n```r\r\n> x := 2 * runif(1) %plan% lazy\r\n$name\r\nx\r\n\r\n$value\r\n2 * runif(1) %plan% lazy\r\n```\r\n\r\n# Miscellaneous\r\nBTW, early on, `%<-%` was also supported.  The main reason for this being dropped what to minimize the risk for conflicts, e.g. [R.utils](https://github.com/HenrikBengtsson/R.utils/blob/master/R/OperatorDelayedAssign.R) defines `%<-%` for delayed assignments and I'm pretty sure I've seen someone else using `%<-%` somewhere, but I don't know if it was in a package or just in a script.   The one in R.utils can most likely be retired, because it basically implements _lazy_ future assignments as in the future package."},"comment":{"url":"https://api.github.com/repos/HenrikBengtsson/future/issues/comments/204804778","html_url":"https://github.com/HenrikBengtsson/future/issues/58#issuecomment-204804778","issue_url":"https://api.github.com/repos/HenrikBengtsson/future/issues/58","id":204804778,"user":{"login":"HenrikBengtsson","id":1616850,"avatar_url":"https://avatars.githubusercontent.com/u/1616850?v=3","gravatar_id":"","url":"https://api.github.com/users/HenrikBengtsson","html_url":"https://github.com/HenrikBengtsson","followers_url":"https://api.github.com/users/HenrikBengtsson/followers","following_url":"https://api.github.com/users/HenrikBengtsson/following{/other_user}","gists_url":"https://api.github.com/users/HenrikBengtsson/gists{/gist_id}","starred_url":"https://api.github.com/users/HenrikBengtsson/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/HenrikBengtsson/subscriptions","organizations_url":"https://api.github.com/users/HenrikBengtsson/orgs","repos_url":"https://api.github.com/users/HenrikBengtsson/repos","events_url":"https://api.github.com/users/HenrikBengtsson/events{/privacy}","received_events_url":"https://api.github.com/users/HenrikBengtsson/received_events","type":"User","site_admin":false},"created_at":"2016-04-02T21:05:13Z","updated_at":"2016-04-02T21:05:13Z","body":"Will go with `%<-%` for now."}}