{"action":"created","comment":{"url":"https://api.github.com/repos/hadley/dplyr/pulls/comments/91566554","pull_request_review_id":12076533,"id":91566554,"diff_hunk":"@@ -172,3 +172,19 @@ is_1d <- function(x) {\n }\n \n is_bare_list <- function(x) is.list(x) && !is.object(x)\n+\n+# Returns the value of x if it is a constant, otherwise returns NULL\n+# The compile() call with the optimize = 3 option performs constant folding\n+# (among other things), it also processes calls like c(), list(), :, and [[.\n+# It returns byte code, which then needs to be evaluated.  If evaluation in\n+# a new empty environment succeeds, the result is a constant and can be returned.\n+# Simply calling eval(x, emptyenv()) won't find c() et al.\n+constfold <- function(x) {\n+  tryCatch(\n+    {\n+      compiled <- compiler::compile(x, options = list(optimize = 3, suppressAll = TRUE))\n+      eval(compiled, new.env(parent = emptyenv()))","path":"R/utils.r","position":15,"original_position":15,"commit_id":"4c75f0e7bb5faef56035e225d6fd0dc0df79285e","original_commit_id":"4c75f0e7bb5faef56035e225d6fd0dc0df79285e","user":{"login":"hadley","id":4196,"avatar_url":"https://avatars.githubusercontent.com/u/4196?v=3","gravatar_id":"","url":"https://api.github.com/users/hadley","html_url":"https://github.com/hadley","followers_url":"https://api.github.com/users/hadley/followers","following_url":"https://api.github.com/users/hadley/following{/other_user}","gists_url":"https://api.github.com/users/hadley/gists{/gist_id}","starred_url":"https://api.github.com/users/hadley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hadley/subscriptions","organizations_url":"https://api.github.com/users/hadley/orgs","repos_url":"https://api.github.com/users/hadley/repos","events_url":"https://api.github.com/users/hadley/events{/privacy}","received_events_url":"https://api.github.com/users/hadley/received_events","type":"User","site_admin":false},"body":"Maybe global is ok though? That would allow us to catch constants defined in vars at a higher level. ","created_at":"2016-12-08T17:43:34Z","updated_at":"2016-12-08T17:43:34Z","html_url":"https://github.com/hadley/dplyr/pull/2298#discussion_r91566554","pull_request_url":"https://api.github.com/repos/hadley/dplyr/pulls/2298","_links":{"self":{"href":"https://api.github.com/repos/hadley/dplyr/pulls/comments/91566554"},"html":{"href":"https://github.com/hadley/dplyr/pull/2298#discussion_r91566554"},"pull_request":{"href":"https://api.github.com/repos/hadley/dplyr/pulls/2298"}}},"pull_request":{"url":"https://api.github.com/repos/hadley/dplyr/pulls/2298","id":97007984,"html_url":"https://github.com/hadley/dplyr/pull/2298","diff_url":"https://github.com/hadley/dplyr/pull/2298.diff","patch_url":"https://github.com/hadley/dplyr/pull/2298.patch","issue_url":"https://api.github.com/repos/hadley/dplyr/issues/2298","number":2298,"state":"open","locked":false,"title":"Constant folding and hybrid tests","user":{"login":"krlmlr","id":1741643,"avatar_url":"https://avatars.githubusercontent.com/u/1741643?v=3","gravatar_id":"","url":"https://api.github.com/users/krlmlr","html_url":"https://github.com/krlmlr","followers_url":"https://api.github.com/users/krlmlr/followers","following_url":"https://api.github.com/users/krlmlr/following{/other_user}","gists_url":"https://api.github.com/users/krlmlr/gists{/gist_id}","starred_url":"https://api.github.com/users/krlmlr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krlmlr/subscriptions","organizations_url":"https://api.github.com/users/krlmlr/orgs","repos_url":"https://api.github.com/users/krlmlr/repos","events_url":"https://api.github.com/users/krlmlr/events{/privacy}","received_events_url":"https://api.github.com/users/krlmlr/received_events","type":"User","site_admin":false},"body":"- New `with_hybrid()`, `without_hybrid()` and `eval_dots()` allow evaluating an expression\r\n    1. inside dplyr, asserting that hybrid evaluation is used\r\n    1. inside dplyr, asserting that hybrid evaluation is not used\r\n    1. outside dplyr\r\n\r\n- Improved and simplified hybrid prototypes\r\n    - using `match.call()` for proper argument matching\r\n    - using constant folding where appropriate\r\n    - better support for complex arguments\r\n\r\n- Comprehensive (?) tests for functions that use hybrid evaluation\r\n\r\nFixes #1691.\r\n\r\nFixes #2143.\r\n\r\n@hadley: PTAL.","created_at":"2016-12-07T21:12:31Z","updated_at":"2016-12-08T17:43:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"177d2545103e3ba977f553f44bcf991715cc670d","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/hadley/dplyr/pulls/2298/commits","review_comments_url":"https://api.github.com/repos/hadley/dplyr/pulls/2298/comments","review_comment_url":"https://api.github.com/repos/hadley/dplyr/pulls/comments{/number}","comments_url":"https://api.github.com/repos/hadley/dplyr/issues/2298/comments","statuses_url":"https://api.github.com/repos/hadley/dplyr/statuses/4c75f0e7bb5faef56035e225d6fd0dc0df79285e","head":{"label":"krlmlr:f-#1691-#2143-hybrid-constfold","ref":"f-#1691-#2143-hybrid-constfold","sha":"4c75f0e7bb5faef56035e225d6fd0dc0df79285e","user":{"login":"krlmlr","id":1741643,"avatar_url":"https://avatars.githubusercontent.com/u/1741643?v=3","gravatar_id":"","url":"https://api.github.com/users/krlmlr","html_url":"https://github.com/krlmlr","followers_url":"https://api.github.com/users/krlmlr/followers","following_url":"https://api.github.com/users/krlmlr/following{/other_user}","gists_url":"https://api.github.com/users/krlmlr/gists{/gist_id}","starred_url":"https://api.github.com/users/krlmlr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krlmlr/subscriptions","organizations_url":"https://api.github.com/users/krlmlr/orgs","repos_url":"https://api.github.com/users/krlmlr/repos","events_url":"https://api.github.com/users/krlmlr/events{/privacy}","received_events_url":"https://api.github.com/users/krlmlr/received_events","type":"User","site_admin":false},"repo":{"id":13851553,"name":"dplyr","full_name":"krlmlr/dplyr","owner":{"login":"krlmlr","id":1741643,"avatar_url":"https://avatars.githubusercontent.com/u/1741643?v=3","gravatar_id":"","url":"https://api.github.com/users/krlmlr","html_url":"https://github.com/krlmlr","followers_url":"https://api.github.com/users/krlmlr/followers","following_url":"https://api.github.com/users/krlmlr/following{/other_user}","gists_url":"https://api.github.com/users/krlmlr/gists{/gist_id}","starred_url":"https://api.github.com/users/krlmlr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krlmlr/subscriptions","organizations_url":"https://api.github.com/users/krlmlr/orgs","repos_url":"https://api.github.com/users/krlmlr/repos","events_url":"https://api.github.com/users/krlmlr/events{/privacy}","received_events_url":"https://api.github.com/users/krlmlr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/krlmlr/dplyr","description":"Plyr specialised for data frames: faster & with remote datastores","fork":true,"url":"https://api.github.com/repos/krlmlr/dplyr","forks_url":"https://api.github.com/repos/krlmlr/dplyr/forks","keys_url":"https://api.github.com/repos/krlmlr/dplyr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/krlmlr/dplyr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/krlmlr/dplyr/teams","hooks_url":"https://api.github.com/repos/krlmlr/dplyr/hooks","issue_events_url":"https://api.github.com/repos/krlmlr/dplyr/issues/events{/number}","events_url":"https://api.github.com/repos/krlmlr/dplyr/events","assignees_url":"https://api.github.com/repos/krlmlr/dplyr/assignees{/user}","branches_url":"https://api.github.com/repos/krlmlr/dplyr/branches{/branch}","tags_url":"https://api.github.com/repos/krlmlr/dplyr/tags","blobs_url":"https://api.github.com/repos/krlmlr/dplyr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/krlmlr/dplyr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/krlmlr/dplyr/git/refs{/sha}","trees_url":"https://api.github.com/repos/krlmlr/dplyr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/krlmlr/dplyr/statuses/{sha}","languages_url":"https://api.github.com/repos/krlmlr/dplyr/languages","stargazers_url":"https://api.github.com/repos/krlmlr/dplyr/stargazers","contributors_url":"https://api.github.com/repos/krlmlr/dplyr/contributors","subscribers_url":"https://api.github.com/repos/krlmlr/dplyr/subscribers","subscription_url":"https://api.github.com/repos/krlmlr/dplyr/subscription","commits_url":"https://api.github.com/repos/krlmlr/dplyr/commits{/sha}","git_commits_url":"https://api.github.com/repos/krlmlr/dplyr/git/commits{/sha}","comments_url":"https://api.github.com/repos/krlmlr/dplyr/comments{/number}","issue_comment_url":"https://api.github.com/repos/krlmlr/dplyr/issues/comments{/number}","contents_url":"https://api.github.com/repos/krlmlr/dplyr/contents/{+path}","compare_url":"https://api.github.com/repos/krlmlr/dplyr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/krlmlr/dplyr/merges","archive_url":"https://api.github.com/repos/krlmlr/dplyr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/krlmlr/dplyr/downloads","issues_url":"https://api.github.com/repos/krlmlr/dplyr/issues{/number}","pulls_url":"https://api.github.com/repos/krlmlr/dplyr/pulls{/number}","milestones_url":"https://api.github.com/repos/krlmlr/dplyr/milestones{/number}","notifications_url":"https://api.github.com/repos/krlmlr/dplyr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/krlmlr/dplyr/labels{/name}","releases_url":"https://api.github.com/repos/krlmlr/dplyr/releases{/id}","deployments_url":"https://api.github.com/repos/krlmlr/dplyr/deployments","created_at":"2013-10-25T04:34:13Z","updated_at":"2016-03-15T10:37:53Z","pushed_at":"2016-12-08T13:42:43Z","git_url":"git://github.com/krlmlr/dplyr.git","ssh_url":"git@github.com:krlmlr/dplyr.git","clone_url":"https://github.com/krlmlr/dplyr.git","svn_url":"https://github.com/krlmlr/dplyr","homepage":null,"size":11852,"stargazers_count":0,"watchers_count":0,"language":"R","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"hadley:master","ref":"master","sha":"30da3a0a3367b30b865629b95412838f1459eefc","user":{"login":"hadley","id":4196,"avatar_url":"https://avatars.githubusercontent.com/u/4196?v=3","gravatar_id":"","url":"https://api.github.com/users/hadley","html_url":"https://github.com/hadley","followers_url":"https://api.github.com/users/hadley/followers","following_url":"https://api.github.com/users/hadley/following{/other_user}","gists_url":"https://api.github.com/users/hadley/gists{/gist_id}","starred_url":"https://api.github.com/users/hadley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hadley/subscriptions","organizations_url":"https://api.github.com/users/hadley/orgs","repos_url":"https://api.github.com/users/hadley/repos","events_url":"https://api.github.com/users/hadley/events{/privacy}","received_events_url":"https://api.github.com/users/hadley/received_events","type":"User","site_admin":false},"repo":{"id":6427813,"name":"dplyr","full_name":"hadley/dplyr","owner":{"login":"hadley","id":4196,"avatar_url":"https://avatars.githubusercontent.com/u/4196?v=3","gravatar_id":"","url":"https://api.github.com/users/hadley","html_url":"https://github.com/hadley","followers_url":"https://api.github.com/users/hadley/followers","following_url":"https://api.github.com/users/hadley/following{/other_user}","gists_url":"https://api.github.com/users/hadley/gists{/gist_id}","starred_url":"https://api.github.com/users/hadley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hadley/subscriptions","organizations_url":"https://api.github.com/users/hadley/orgs","repos_url":"https://api.github.com/users/hadley/repos","events_url":"https://api.github.com/users/hadley/events{/privacy}","received_events_url":"https://api.github.com/users/hadley/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hadley/dplyr","description":"Dplyr: A grammar of data manipulation","fork":false,"url":"https://api.github.com/repos/hadley/dplyr","forks_url":"https://api.github.com/repos/hadley/dplyr/forks","keys_url":"https://api.github.com/repos/hadley/dplyr/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hadley/dplyr/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hadley/dplyr/teams","hooks_url":"https://api.github.com/repos/hadley/dplyr/hooks","issue_events_url":"https://api.github.com/repos/hadley/dplyr/issues/events{/number}","events_url":"https://api.github.com/repos/hadley/dplyr/events","assignees_url":"https://api.github.com/repos/hadley/dplyr/assignees{/user}","branches_url":"https://api.github.com/repos/hadley/dplyr/branches{/branch}","tags_url":"https://api.github.com/repos/hadley/dplyr/tags","blobs_url":"https://api.github.com/repos/hadley/dplyr/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hadley/dplyr/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hadley/dplyr/git/refs{/sha}","trees_url":"https://api.github.com/repos/hadley/dplyr/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hadley/dplyr/statuses/{sha}","languages_url":"https://api.github.com/repos/hadley/dplyr/languages","stargazers_url":"https://api.github.com/repos/hadley/dplyr/stargazers","contributors_url":"https://api.github.com/repos/hadley/dplyr/contributors","subscribers_url":"https://api.github.com/repos/hadley/dplyr/subscribers","subscription_url":"https://api.github.com/repos/hadley/dplyr/subscription","commits_url":"https://api.github.com/repos/hadley/dplyr/commits{/sha}","git_commits_url":"https://api.github.com/repos/hadley/dplyr/git/commits{/sha}","comments_url":"https://api.github.com/repos/hadley/dplyr/comments{/number}","issue_comment_url":"https://api.github.com/repos/hadley/dplyr/issues/comments{/number}","contents_url":"https://api.github.com/repos/hadley/dplyr/contents/{+path}","compare_url":"https://api.github.com/repos/hadley/dplyr/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hadley/dplyr/merges","archive_url":"https://api.github.com/repos/hadley/dplyr/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hadley/dplyr/downloads","issues_url":"https://api.github.com/repos/hadley/dplyr/issues{/number}","pulls_url":"https://api.github.com/repos/hadley/dplyr/pulls{/number}","milestones_url":"https://api.github.com/repos/hadley/dplyr/milestones{/number}","notifications_url":"https://api.github.com/repos/hadley/dplyr/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hadley/dplyr/labels{/name}","releases_url":"https://api.github.com/repos/hadley/dplyr/releases{/id}","deployments_url":"https://api.github.com/repos/hadley/dplyr/deployments","created_at":"2012-10-28T13:39:17Z","updated_at":"2016-12-07T13:55:38Z","pushed_at":"2016-12-08T14:58:46Z","git_url":"git://github.com/hadley/dplyr.git","ssh_url":"git@github.com:hadley/dplyr.git","clone_url":"https://github.com/hadley/dplyr.git","svn_url":"https://github.com/hadley/dplyr","homepage":"","size":13383,"stargazers_count":1524,"watchers_count":1524,"language":"R","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":615,"mirror_url":null,"open_issues_count":237,"forks":615,"open_issues":237,"watchers":1524,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/hadley/dplyr/pulls/2298"},"html":{"href":"https://github.com/hadley/dplyr/pull/2298"},"issue":{"href":"https://api.github.com/repos/hadley/dplyr/issues/2298"},"comments":{"href":"https://api.github.com/repos/hadley/dplyr/issues/2298/comments"},"review_comments":{"href":"https://api.github.com/repos/hadley/dplyr/pulls/2298/comments"},"review_comment":{"href":"https://api.github.com/repos/hadley/dplyr/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/hadley/dplyr/pulls/2298/commits"},"statuses":{"href":"https://api.github.com/repos/hadley/dplyr/statuses/4c75f0e7bb5faef56035e225d6fd0dc0df79285e"}}}}
{"actor":{"display_login":"hadley"}}