{"action":"created","comment":{"url":"https://api.github.com/repos/jeremyong/Selene/pulls/comments/41499921","id":41499921,"diff_hunk":"@@ -134,9 +134,14 @@ class State {\n     }\n \n     bool operator()(const char *code) {\n-        bool result = !luaL_dostring(_l, code);\n-        if(result) lua_settop(_l, 0);\n-        return result;\n+        ResetStackOnScopeExit savedStack(_l);\n+        int status = luaL_dostring(_l, code);\n+        if(status) {\n+            _exception_handler->Handle_top_of_stack(status, _l);\n+            return false;\n+        }\n+        savedStack.KeepChanges();","path":"include/selene/State.h","position":13,"original_position":13,"commit_id":"dee44e5f502d997ca1532f19f0cfc7ccd243dfba","original_commit_id":"dee44e5f502d997ca1532f19f0cfc7ccd243dfba","user":{"login":"AnonymousProgrammerLandau","id":14163257,"avatar_url":"https://avatars.githubusercontent.com/u/14163257?v=3","gravatar_id":"","url":"https://api.github.com/users/AnonymousProgrammerLandau","html_url":"https://github.com/AnonymousProgrammerLandau","followers_url":"https://api.github.com/users/AnonymousProgrammerLandau/followers","following_url":"https://api.github.com/users/AnonymousProgrammerLandau/following{/other_user}","gists_url":"https://api.github.com/users/AnonymousProgrammerLandau/gists{/gist_id}","starred_url":"https://api.github.com/users/AnonymousProgrammerLandau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnonymousProgrammerLandau/subscriptions","organizations_url":"https://api.github.com/users/AnonymousProgrammerLandau/orgs","repos_url":"https://api.github.com/users/AnonymousProgrammerLandau/repos","events_url":"https://api.github.com/users/AnonymousProgrammerLandau/events{/privacy}","received_events_url":"https://api.github.com/users/AnonymousProgrammerLandau/received_events","type":"User","site_admin":false},"body":"The member functions `Load(...)`, `OpenLib(...)`, `Push(...)` and `operator()(...)` leave objects on the stack. There is no function to remove objects from the stack.\r\n 1. Make them to not leave objects on the stack and remove `Push(...)` and `Read(...)`.\r\n 2. Add `Pop(...)` or similar functions.\r\nI see no real use of managing objects on the stack at this level of abstraction - apart from using Lua's implicit type conversions. The latter seems unimportant enough to me to favor item 1.\r\n@jeremyong: Am I missing a use case?","created_at":"2015-10-08T10:54:21Z","updated_at":"2015-10-08T10:54:21Z","html_url":"https://github.com/jeremyong/Selene/pull/105#discussion_r41499921","pull_request_url":"https://api.github.com/repos/jeremyong/Selene/pulls/105","_links":{"self":{"href":"https://api.github.com/repos/jeremyong/Selene/pulls/comments/41499921"},"html":{"href":"https://github.com/jeremyong/Selene/pull/105#discussion_r41499921"},"pull_request":{"href":"https://api.github.com/repos/jeremyong/Selene/pulls/105"}}},"pull_request":{"url":"https://api.github.com/repos/jeremyong/Selene/pulls/105","id":46899858,"html_url":"https://github.com/jeremyong/Selene/pull/105","diff_url":"https://github.com/jeremyong/Selene/pull/105.diff","patch_url":"https://github.com/jeremyong/Selene/pull/105.patch","issue_url":"https://api.github.com/repos/jeremyong/Selene/issues/105","number":105,"state":"open","locked":false,"title":"Use resource handles","user":{"login":"AnonymousProgrammerLandau","id":14163257,"avatar_url":"https://avatars.githubusercontent.com/u/14163257?v=3","gravatar_id":"","url":"https://api.github.com/users/AnonymousProgrammerLandau","html_url":"https://github.com/AnonymousProgrammerLandau","followers_url":"https://api.github.com/users/AnonymousProgrammerLandau/followers","following_url":"https://api.github.com/users/AnonymousProgrammerLandau/following{/other_user}","gists_url":"https://api.github.com/users/AnonymousProgrammerLandau/gists{/gist_id}","starred_url":"https://api.github.com/users/AnonymousProgrammerLandau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnonymousProgrammerLandau/subscriptions","organizations_url":"https://api.github.com/users/AnonymousProgrammerLandau/orgs","repos_url":"https://api.github.com/users/AnonymousProgrammerLandau/repos","events_url":"https://api.github.com/users/AnonymousProgrammerLandau/events{/privacy}","received_events_url":"https://api.github.com/users/AnonymousProgrammerLandau/received_events","type":"User","site_admin":false},"body":"I think the library benefits from further use of resource handles (RAII).\r\n\r\n - [x] Encapsulate in a type the concept of calling exactly once to Lua for statements like `Res r = state[\"lua_function\"](...)`.\r\n - [ ] Use the destructor of a type to clear the stack (`lua_State`) after modifying activities.\r\n","created_at":"2015-10-06T13:06:50Z","updated_at":"2015-10-08T10:54:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"eb357ad8d293a7c6e97960f6fc7120e2da886e82","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/jeremyong/Selene/pulls/105/commits","review_comments_url":"https://api.github.com/repos/jeremyong/Selene/pulls/105/comments","review_comment_url":"https://api.github.com/repos/jeremyong/Selene/pulls/comments{/number}","comments_url":"https://api.github.com/repos/jeremyong/Selene/issues/105/comments","statuses_url":"https://api.github.com/repos/jeremyong/Selene/statuses/dee44e5f502d997ca1532f19f0cfc7ccd243dfba","head":{"label":"AnonymousProgrammerLandau:useResourceHandles","ref":"useResourceHandles","sha":"dee44e5f502d997ca1532f19f0cfc7ccd243dfba","user":{"login":"AnonymousProgrammerLandau","id":14163257,"avatar_url":"https://avatars.githubusercontent.com/u/14163257?v=3","gravatar_id":"","url":"https://api.github.com/users/AnonymousProgrammerLandau","html_url":"https://github.com/AnonymousProgrammerLandau","followers_url":"https://api.github.com/users/AnonymousProgrammerLandau/followers","following_url":"https://api.github.com/users/AnonymousProgrammerLandau/following{/other_user}","gists_url":"https://api.github.com/users/AnonymousProgrammerLandau/gists{/gist_id}","starred_url":"https://api.github.com/users/AnonymousProgrammerLandau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnonymousProgrammerLandau/subscriptions","organizations_url":"https://api.github.com/users/AnonymousProgrammerLandau/orgs","repos_url":"https://api.github.com/users/AnonymousProgrammerLandau/repos","events_url":"https://api.github.com/users/AnonymousProgrammerLandau/events{/privacy}","received_events_url":"https://api.github.com/users/AnonymousProgrammerLandau/received_events","type":"User","site_admin":false},"repo":{"id":42055620,"name":"Selene","full_name":"AnonymousProgrammerLandau/Selene","owner":{"login":"AnonymousProgrammerLandau","id":14163257,"avatar_url":"https://avatars.githubusercontent.com/u/14163257?v=3","gravatar_id":"","url":"https://api.github.com/users/AnonymousProgrammerLandau","html_url":"https://github.com/AnonymousProgrammerLandau","followers_url":"https://api.github.com/users/AnonymousProgrammerLandau/followers","following_url":"https://api.github.com/users/AnonymousProgrammerLandau/following{/other_user}","gists_url":"https://api.github.com/users/AnonymousProgrammerLandau/gists{/gist_id}","starred_url":"https://api.github.com/users/AnonymousProgrammerLandau/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnonymousProgrammerLandau/subscriptions","organizations_url":"https://api.github.com/users/AnonymousProgrammerLandau/orgs","repos_url":"https://api.github.com/users/AnonymousProgrammerLandau/repos","events_url":"https://api.github.com/users/AnonymousProgrammerLandau/events{/privacy}","received_events_url":"https://api.github.com/users/AnonymousProgrammerLandau/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/AnonymousProgrammerLandau/Selene","description":"Simple C++11 friendly header-only bindings to Lua","fork":true,"url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene","forks_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/forks","keys_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/keys{/key_id}","collaborators_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/teams","hooks_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/hooks","issue_events_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/issues/events{/number}","events_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/events","assignees_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/assignees{/user}","branches_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/branches{/branch}","tags_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/tags","blobs_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/git/refs{/sha}","trees_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/git/trees{/sha}","statuses_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/statuses/{sha}","languages_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/languages","stargazers_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/stargazers","contributors_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/contributors","subscribers_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/subscribers","subscription_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/subscription","commits_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/commits{/sha}","git_commits_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/git/commits{/sha}","comments_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/comments{/number}","issue_comment_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/issues/comments{/number}","contents_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/contents/{+path}","compare_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/compare/{base}...{head}","merges_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/merges","archive_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/downloads","issues_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/issues{/number}","pulls_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/pulls{/number}","milestones_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/milestones{/number}","notifications_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/labels{/name}","releases_url":"https://api.github.com/repos/AnonymousProgrammerLandau/Selene/releases{/id}","created_at":"2015-09-07T13:52:44Z","updated_at":"2015-09-09T09:07:48Z","pushed_at":"2015-10-08T10:20:12Z","git_url":"git://github.com/AnonymousProgrammerLandau/Selene.git","ssh_url":"git@github.com:AnonymousProgrammerLandau/Selene.git","clone_url":"https://github.com/AnonymousProgrammerLandau/Selene.git","svn_url":"https://github.com/AnonymousProgrammerLandau/Selene","homepage":"","size":332,"stargazers_count":0,"watchers_count":0,"language":"C++","has_issues":false,"has_downloads":true,"has_wiki":false,"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":"jeremyong:master","ref":"master","sha":"b8924913669a744f2b6de12564ba31ae7601e197","user":{"login":"jeremyong","id":250149,"avatar_url":"https://avatars.githubusercontent.com/u/250149?v=3","gravatar_id":"","url":"https://api.github.com/users/jeremyong","html_url":"https://github.com/jeremyong","followers_url":"https://api.github.com/users/jeremyong/followers","following_url":"https://api.github.com/users/jeremyong/following{/other_user}","gists_url":"https://api.github.com/users/jeremyong/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremyong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremyong/subscriptions","organizations_url":"https://api.github.com/users/jeremyong/orgs","repos_url":"https://api.github.com/users/jeremyong/repos","events_url":"https://api.github.com/users/jeremyong/events{/privacy}","received_events_url":"https://api.github.com/users/jeremyong/received_events","type":"User","site_admin":false},"repo":{"id":15782383,"name":"Selene","full_name":"jeremyong/Selene","owner":{"login":"jeremyong","id":250149,"avatar_url":"https://avatars.githubusercontent.com/u/250149?v=3","gravatar_id":"","url":"https://api.github.com/users/jeremyong","html_url":"https://github.com/jeremyong","followers_url":"https://api.github.com/users/jeremyong/followers","following_url":"https://api.github.com/users/jeremyong/following{/other_user}","gists_url":"https://api.github.com/users/jeremyong/gists{/gist_id}","starred_url":"https://api.github.com/users/jeremyong/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jeremyong/subscriptions","organizations_url":"https://api.github.com/users/jeremyong/orgs","repos_url":"https://api.github.com/users/jeremyong/repos","events_url":"https://api.github.com/users/jeremyong/events{/privacy}","received_events_url":"https://api.github.com/users/jeremyong/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/jeremyong/Selene","description":"Simple C++11 friendly header-only bindings to Lua","fork":false,"url":"https://api.github.com/repos/jeremyong/Selene","forks_url":"https://api.github.com/repos/jeremyong/Selene/forks","keys_url":"https://api.github.com/repos/jeremyong/Selene/keys{/key_id}","collaborators_url":"https://api.github.com/repos/jeremyong/Selene/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/jeremyong/Selene/teams","hooks_url":"https://api.github.com/repos/jeremyong/Selene/hooks","issue_events_url":"https://api.github.com/repos/jeremyong/Selene/issues/events{/number}","events_url":"https://api.github.com/repos/jeremyong/Selene/events","assignees_url":"https://api.github.com/repos/jeremyong/Selene/assignees{/user}","branches_url":"https://api.github.com/repos/jeremyong/Selene/branches{/branch}","tags_url":"https://api.github.com/repos/jeremyong/Selene/tags","blobs_url":"https://api.github.com/repos/jeremyong/Selene/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/jeremyong/Selene/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/jeremyong/Selene/git/refs{/sha}","trees_url":"https://api.github.com/repos/jeremyong/Selene/git/trees{/sha}","statuses_url":"https://api.github.com/repos/jeremyong/Selene/statuses/{sha}","languages_url":"https://api.github.com/repos/jeremyong/Selene/languages","stargazers_url":"https://api.github.com/repos/jeremyong/Selene/stargazers","contributors_url":"https://api.github.com/repos/jeremyong/Selene/contributors","subscribers_url":"https://api.github.com/repos/jeremyong/Selene/subscribers","subscription_url":"https://api.github.com/repos/jeremyong/Selene/subscription","commits_url":"https://api.github.com/repos/jeremyong/Selene/commits{/sha}","git_commits_url":"https://api.github.com/repos/jeremyong/Selene/git/commits{/sha}","comments_url":"https://api.github.com/repos/jeremyong/Selene/comments{/number}","issue_comment_url":"https://api.github.com/repos/jeremyong/Selene/issues/comments{/number}","contents_url":"https://api.github.com/repos/jeremyong/Selene/contents/{+path}","compare_url":"https://api.github.com/repos/jeremyong/Selene/compare/{base}...{head}","merges_url":"https://api.github.com/repos/jeremyong/Selene/merges","archive_url":"https://api.github.com/repos/jeremyong/Selene/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/jeremyong/Selene/downloads","issues_url":"https://api.github.com/repos/jeremyong/Selene/issues{/number}","pulls_url":"https://api.github.com/repos/jeremyong/Selene/pulls{/number}","milestones_url":"https://api.github.com/repos/jeremyong/Selene/milestones{/number}","notifications_url":"https://api.github.com/repos/jeremyong/Selene/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/jeremyong/Selene/labels{/name}","releases_url":"https://api.github.com/repos/jeremyong/Selene/releases{/id}","created_at":"2014-01-09T23:06:00Z","updated_at":"2015-10-08T06:51:17Z","pushed_at":"2015-10-08T10:20:13Z","git_url":"git://github.com/jeremyong/Selene.git","ssh_url":"git@github.com:jeremyong/Selene.git","clone_url":"https://github.com/jeremyong/Selene.git","svn_url":"https://github.com/jeremyong/Selene","homepage":"","size":1128,"stargazers_count":336,"watchers_count":336,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":61,"mirror_url":null,"open_issues_count":17,"forks":61,"open_issues":17,"watchers":336,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/jeremyong/Selene/pulls/105"},"html":{"href":"https://github.com/jeremyong/Selene/pull/105"},"issue":{"href":"https://api.github.com/repos/jeremyong/Selene/issues/105"},"comments":{"href":"https://api.github.com/repos/jeremyong/Selene/issues/105/comments"},"review_comments":{"href":"https://api.github.com/repos/jeremyong/Selene/pulls/105/comments"},"review_comment":{"href":"https://api.github.com/repos/jeremyong/Selene/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/jeremyong/Selene/pulls/105/commits"},"statuses":{"href":"https://api.github.com/repos/jeremyong/Selene/statuses/dee44e5f502d997ca1532f19f0cfc7ccd243dfba"}}}}