{"action":"created","comment":{"url":"https://api.github.com/repos/ripple/rippled/pulls/comments/86034357","pull_request_review_id":6713875,"id":86034357,"diff_hunk":"@@ -378,12 +446,13 @@ BookStep<TIn, TOut>::revImp (\n       Return true to continue to receive offers, false to stop receiving offers.\n     */\n     auto eachOffer =\n-        [&](TOffer<TIn, TOut>& offer,\n-            TAmounts<TIn, TOut> const& ofrAmt,\n-            TAmounts<TIn, TOut> const& stpAmt,\n-            TOut const& ownerGives,\n-            std::uint32_t transferRateIn,\n-            std::uint32_t transferRateOut) mutable -> bool\n+        [this, &sb, &out, &result, &remainingOut, &savedIns, &savedOuts]","path":"src/ripple/app/paths/impl/BookStep.cpp","position":210,"original_position":208,"commit_id":"50a36fcb5cd3b904cf01bef9e09d93f71f73b8f1","original_commit_id":"f357f77a097c47411fa508e8b1adaf86239d9591","user":{"login":"vinniefalco","id":1503976,"avatar_url":"https://avatars.githubusercontent.com/u/1503976?v=3","gravatar_id":"","url":"https://api.github.com/users/vinniefalco","html_url":"https://github.com/vinniefalco","followers_url":"https://api.github.com/users/vinniefalco/followers","following_url":"https://api.github.com/users/vinniefalco/following{/other_user}","gists_url":"https://api.github.com/users/vinniefalco/gists{/gist_id}","starred_url":"https://api.github.com/users/vinniefalco/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vinniefalco/subscriptions","organizations_url":"https://api.github.com/users/vinniefalco/orgs","repos_url":"https://api.github.com/users/vinniefalco/repos","events_url":"https://api.github.com/users/vinniefalco/events{/privacy}","received_events_url":"https://api.github.com/users/vinniefalco/received_events","type":"User","site_admin":false},"body":"I disagree with Scott Meyer on this one. I think of a lambda as part of the enclosing function. Its a convenience that lets you essentially create \"sub-functions\". The idea is that they are somewhat encapsulated and therefore, easier to reason about. And they make the enclosing function similarly easier to reason about. Here's a perfect example of the use of a lambda for that sort of thing (at the end of this message).\r\n\r\nSo, what about the capture mode? I find that there are usually two types of lambdas. Pure functions that operate only on their inputs (function parameters), and those that mutate variables in the enclosing function scope. For the first kind, they don't need to capture in the first place so its a moot point. For the second kind, I don't see much gain from explicitly listing each individual parameter. You need what you need, no more and no less. Importing more than you need doesn't cost anything and its a convenient shorthand. Quite frankly the lambda shown above, in BookStep.cpp, has a ridiculous list of captures. I agree with Scott's assessment - one capture is probably okay but in this case, its just noise.\r\n\r\nListing:\r\n```\r\ntemplate<class _>\r\nbool\r\nutf8_checker_t<_>::write(std::uint8_t const* in, std::size_t const size)\r\n{\r\n    auto const valid =\r\n        [](std::uint8_t const*& in)\r\n        {\r\n            if (*in < 128)\r\n            {\r\n                ++in;\r\n                return true;\r\n            }\r\n            if ((in[0] & 0x60) == 0x40)\r\n            {\r\n                if ((in[0] & 0xfe) == 0xc0 ||\r\n                    (in[1] & 0xc0) != 0x80)\r\n                        return false;\r\n                in += 2;\r\n                return true;\r\n            }\r\n            if ((in[0] & 0xf0) == 0xe0)\r\n            {\r\n                if ((in[1] & 0xc0) != 0x80 ||\r\n                    (in[2] & 0xc0) != 0x80 ||\r\n                    (in[0] == 224 && in[1] < 160) ||\r\n                    (in[0] == 237 && in[1] > 159))\r\n                        return false;\r\n                in += 3;\r\n                return true;\r\n            }\r\n            if ((in[0] & 0xf8) == 0xf0)\r\n            {\r\n                if (in[0] > 244 ||\r\n                    (in[1] & 0xc0) != 0x80 ||\r\n                    (in[2] & 0xc0) != 0x80 ||\r\n                    (in[3] & 0xc0) != 0x80 ||\r\n                    (in[0] == 240 && in[1] < 144) ||\r\n                    (in[0] == 244 && in[1] > 143))\r\n                        return false;\r\n                in += 4;\r\n                return true;\r\n            }\r\n            return false;\r\n        };\r\n    auto const needed =\r\n        [](std::uint8_t const in)\r\n        {\r\n            if (in < 128)\r\n                return 1;\r\n            if (in < 194)\r\n                return 0;\r\n            if (in < 224)\r\n                return 2;\r\n            if (in < 240)\r\n                return 3;\r\n            if (in < 245)\r\n                return 4;\r\n            return 0;\r\n        };\r\n\r\n    auto const end = in + size;\r\n    if (need_ > 0)\r\n    {\r\n        auto n = std::min(size, need_);\r\n        need_ -= n;\r\n        while(n--)\r\n            *p_++ = *in++;\r\n        if(need_ > 0)\r\n        {\r\n            BOOST_ASSERT(in == end);\r\n            return true;\r\n        }\r\n        std::uint8_t const* p = &have_[0];\r\n        if (! valid(p))\r\n            return false;\r\n        p_ = have_;\r\n    }\r\n\r\n    auto const last = in + size - 3;\r\n    while(in < last)\r\n        if(! valid(in))\r\n            return false;\r\n\r\n    for(;;)\r\n    {\r\n        auto n = end - in;\r\n        if(! n)\r\n            break;\r\n        auto const need = needed(*in);\r\n        if (need == 0)\r\n            return false;\r\n        if(need <= n)\r\n        {\r\n            if(! valid(in))\r\n                return false;\r\n        }\r\n        else\r\n        {\r\n            need_ = need - n;\r\n            while(n--)\r\n                *p_++ = *in++;\r\n            break;\r\n        }\r\n    }\r\n    return true;\r\n}\r\n```","created_at":"2016-11-01T21:56:58Z","updated_at":"2016-11-01T21:56:59Z","html_url":"https://github.com/ripple/rippled/pull/1884#discussion_r86034357","pull_request_url":"https://api.github.com/repos/ripple/rippled/pulls/1884","_links":{"self":{"href":"https://api.github.com/repos/ripple/rippled/pulls/comments/86034357"},"html":{"href":"https://github.com/ripple/rippled/pull/1884#discussion_r86034357"},"pull_request":{"href":"https://api.github.com/repos/ripple/rippled/pulls/1884"}}},"pull_request":{"url":"https://api.github.com/repos/ripple/rippled/pulls/1884","id":90471816,"html_url":"https://github.com/ripple/rippled/pull/1884","diff_url":"https://github.com/ripple/rippled/pull/1884.diff","patch_url":"https://github.com/ripple/rippled/pull/1884.patch","issue_url":"https://api.github.com/repos/ripple/rippled/issues/1884","number":1884,"state":"open","locked":false,"title":"Use payment flow code for offer crossing (RIPD-1094):","user":{"login":"scottschurr","id":7840379,"avatar_url":"https://avatars.githubusercontent.com/u/7840379?v=3","gravatar_id":"","url":"https://api.github.com/users/scottschurr","html_url":"https://github.com/scottschurr","followers_url":"https://api.github.com/users/scottschurr/followers","following_url":"https://api.github.com/users/scottschurr/following{/other_user}","gists_url":"https://api.github.com/users/scottschurr/gists{/gist_id}","starred_url":"https://api.github.com/users/scottschurr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scottschurr/subscriptions","organizations_url":"https://api.github.com/users/scottschurr/orgs","repos_url":"https://api.github.com/users/scottschurr/repos","events_url":"https://api.github.com/users/scottschurr/events{/privacy}","received_events_url":"https://api.github.com/users/scottschurr/received_events","type":"User","site_admin":false},"body":"Replace Taker.cpp with calls to the new payment flow code.\n\nThis change required a number of tweaks in the payment flow code.  These tweaks are conditionalized on whether or not offer crossing is taking place.  The flag is explicitly passed as a parameter to the flow code.\n\nFor testing, a class was added that identifies differences in the contents of two PaymentSandboxes.  That code may be reusable in the future.\n\nNone of the V1 offer crossing code is removed.  Both versions of the code are co-resident to support an amendment cut-over.\n\nThe code that identifies differences between V1 and V2 offer crossing is also on an amendment.  That makes it easy to enable or disable difference logging by changing the config file.  This approach models what was done with the payment Flow code.  The differencing code should never be enabled on the network.\n\nExtensive offer crossing unit tests are added to examine and verify the behavior of corner cases.  The tests are currently configured to run against both V1 and V2 offer crossing.  This gives us confidence that most cases run identically and some of the (few) differences in behavior are documented.\n","created_at":"2016-10-22T06:11:21Z","updated_at":"2016-11-01T21:56:59Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b7c87c768b957205f5486a9d0e23e5b6c47b7e80","assignee":{"login":"nbougalis","id":5085415,"avatar_url":"https://avatars.githubusercontent.com/u/5085415?v=3","gravatar_id":"","url":"https://api.github.com/users/nbougalis","html_url":"https://github.com/nbougalis","followers_url":"https://api.github.com/users/nbougalis/followers","following_url":"https://api.github.com/users/nbougalis/following{/other_user}","gists_url":"https://api.github.com/users/nbougalis/gists{/gist_id}","starred_url":"https://api.github.com/users/nbougalis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nbougalis/subscriptions","organizations_url":"https://api.github.com/users/nbougalis/orgs","repos_url":"https://api.github.com/users/nbougalis/repos","events_url":"https://api.github.com/users/nbougalis/events{/privacy}","received_events_url":"https://api.github.com/users/nbougalis/received_events","type":"User","site_admin":false},"assignees":[{"login":"nbougalis","id":5085415,"avatar_url":"https://avatars.githubusercontent.com/u/5085415?v=3","gravatar_id":"","url":"https://api.github.com/users/nbougalis","html_url":"https://github.com/nbougalis","followers_url":"https://api.github.com/users/nbougalis/followers","following_url":"https://api.github.com/users/nbougalis/following{/other_user}","gists_url":"https://api.github.com/users/nbougalis/gists{/gist_id}","starred_url":"https://api.github.com/users/nbougalis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nbougalis/subscriptions","organizations_url":"https://api.github.com/users/nbougalis/orgs","repos_url":"https://api.github.com/users/nbougalis/repos","events_url":"https://api.github.com/users/nbougalis/events{/privacy}","received_events_url":"https://api.github.com/users/nbougalis/received_events","type":"User","site_admin":false},{"login":"seelabs","id":5853458,"avatar_url":"https://avatars.githubusercontent.com/u/5853458?v=3","gravatar_id":"","url":"https://api.github.com/users/seelabs","html_url":"https://github.com/seelabs","followers_url":"https://api.github.com/users/seelabs/followers","following_url":"https://api.github.com/users/seelabs/following{/other_user}","gists_url":"https://api.github.com/users/seelabs/gists{/gist_id}","starred_url":"https://api.github.com/users/seelabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/seelabs/subscriptions","organizations_url":"https://api.github.com/users/seelabs/orgs","repos_url":"https://api.github.com/users/seelabs/repos","events_url":"https://api.github.com/users/seelabs/events{/privacy}","received_events_url":"https://api.github.com/users/seelabs/received_events","type":"User","site_admin":false}],"milestone":null,"commits_url":"https://api.github.com/repos/ripple/rippled/pulls/1884/commits","review_comments_url":"https://api.github.com/repos/ripple/rippled/pulls/1884/comments","review_comment_url":"https://api.github.com/repos/ripple/rippled/pulls/comments{/number}","comments_url":"https://api.github.com/repos/ripple/rippled/issues/1884/comments","statuses_url":"https://api.github.com/repos/ripple/rippled/statuses/50a36fcb5cd3b904cf01bef9e09d93f71f73b8f1","head":{"label":"scottschurr:flow-offer-cross-8","ref":"flow-offer-cross-8","sha":"50a36fcb5cd3b904cf01bef9e09d93f71f73b8f1","user":{"login":"scottschurr","id":7840379,"avatar_url":"https://avatars.githubusercontent.com/u/7840379?v=3","gravatar_id":"","url":"https://api.github.com/users/scottschurr","html_url":"https://github.com/scottschurr","followers_url":"https://api.github.com/users/scottschurr/followers","following_url":"https://api.github.com/users/scottschurr/following{/other_user}","gists_url":"https://api.github.com/users/scottschurr/gists{/gist_id}","starred_url":"https://api.github.com/users/scottschurr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scottschurr/subscriptions","organizations_url":"https://api.github.com/users/scottschurr/orgs","repos_url":"https://api.github.com/users/scottschurr/repos","events_url":"https://api.github.com/users/scottschurr/events{/privacy}","received_events_url":"https://api.github.com/users/scottschurr/received_events","type":"User","site_admin":false},"repo":{"id":20703176,"name":"rippled","full_name":"scottschurr/rippled","owner":{"login":"scottschurr","id":7840379,"avatar_url":"https://avatars.githubusercontent.com/u/7840379?v=3","gravatar_id":"","url":"https://api.github.com/users/scottschurr","html_url":"https://github.com/scottschurr","followers_url":"https://api.github.com/users/scottschurr/followers","following_url":"https://api.github.com/users/scottschurr/following{/other_user}","gists_url":"https://api.github.com/users/scottschurr/gists{/gist_id}","starred_url":"https://api.github.com/users/scottschurr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/scottschurr/subscriptions","organizations_url":"https://api.github.com/users/scottschurr/orgs","repos_url":"https://api.github.com/users/scottschurr/repos","events_url":"https://api.github.com/users/scottschurr/events{/privacy}","received_events_url":"https://api.github.com/users/scottschurr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/scottschurr/rippled","description":"Ripple peer-to-peer network daemon","fork":true,"url":"https://api.github.com/repos/scottschurr/rippled","forks_url":"https://api.github.com/repos/scottschurr/rippled/forks","keys_url":"https://api.github.com/repos/scottschurr/rippled/keys{/key_id}","collaborators_url":"https://api.github.com/repos/scottschurr/rippled/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/scottschurr/rippled/teams","hooks_url":"https://api.github.com/repos/scottschurr/rippled/hooks","issue_events_url":"https://api.github.com/repos/scottschurr/rippled/issues/events{/number}","events_url":"https://api.github.com/repos/scottschurr/rippled/events","assignees_url":"https://api.github.com/repos/scottschurr/rippled/assignees{/user}","branches_url":"https://api.github.com/repos/scottschurr/rippled/branches{/branch}","tags_url":"https://api.github.com/repos/scottschurr/rippled/tags","blobs_url":"https://api.github.com/repos/scottschurr/rippled/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/scottschurr/rippled/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/scottschurr/rippled/git/refs{/sha}","trees_url":"https://api.github.com/repos/scottschurr/rippled/git/trees{/sha}","statuses_url":"https://api.github.com/repos/scottschurr/rippled/statuses/{sha}","languages_url":"https://api.github.com/repos/scottschurr/rippled/languages","stargazers_url":"https://api.github.com/repos/scottschurr/rippled/stargazers","contributors_url":"https://api.github.com/repos/scottschurr/rippled/contributors","subscribers_url":"https://api.github.com/repos/scottschurr/rippled/subscribers","subscription_url":"https://api.github.com/repos/scottschurr/rippled/subscription","commits_url":"https://api.github.com/repos/scottschurr/rippled/commits{/sha}","git_commits_url":"https://api.github.com/repos/scottschurr/rippled/git/commits{/sha}","comments_url":"https://api.github.com/repos/scottschurr/rippled/comments{/number}","issue_comment_url":"https://api.github.com/repos/scottschurr/rippled/issues/comments{/number}","contents_url":"https://api.github.com/repos/scottschurr/rippled/contents/{+path}","compare_url":"https://api.github.com/repos/scottschurr/rippled/compare/{base}...{head}","merges_url":"https://api.github.com/repos/scottschurr/rippled/merges","archive_url":"https://api.github.com/repos/scottschurr/rippled/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/scottschurr/rippled/downloads","issues_url":"https://api.github.com/repos/scottschurr/rippled/issues{/number}","pulls_url":"https://api.github.com/repos/scottschurr/rippled/pulls{/number}","milestones_url":"https://api.github.com/repos/scottschurr/rippled/milestones{/number}","notifications_url":"https://api.github.com/repos/scottschurr/rippled/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/scottschurr/rippled/labels{/name}","releases_url":"https://api.github.com/repos/scottschurr/rippled/releases{/id}","deployments_url":"https://api.github.com/repos/scottschurr/rippled/deployments","created_at":"2014-06-10T21:58:27Z","updated_at":"2016-01-15T01:44:41Z","pushed_at":"2016-11-01T16:15:00Z","git_url":"git://github.com/scottschurr/rippled.git","ssh_url":"git@github.com:scottschurr/rippled.git","clone_url":"https://github.com/scottschurr/rippled.git","svn_url":"https://github.com/scottschurr/rippled","homepage":"https://ripple.com","size":78957,"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":"develop"}},"base":{"label":"ripple:develop","ref":"develop","sha":"7688a97d9571ad76c1d4a2e074fb60fd7f9cca97","user":{"login":"ripple","id":3165523,"avatar_url":"https://avatars.githubusercontent.com/u/3165523?v=3","gravatar_id":"","url":"https://api.github.com/users/ripple","html_url":"https://github.com/ripple","followers_url":"https://api.github.com/users/ripple/followers","following_url":"https://api.github.com/users/ripple/following{/other_user}","gists_url":"https://api.github.com/users/ripple/gists{/gist_id}","starred_url":"https://api.github.com/users/ripple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ripple/subscriptions","organizations_url":"https://api.github.com/users/ripple/orgs","repos_url":"https://api.github.com/users/ripple/repos","events_url":"https://api.github.com/users/ripple/events{/privacy}","received_events_url":"https://api.github.com/users/ripple/received_events","type":"Organization","site_admin":false},"repo":{"id":2724167,"name":"rippled","full_name":"ripple/rippled","owner":{"login":"ripple","id":3165523,"avatar_url":"https://avatars.githubusercontent.com/u/3165523?v=3","gravatar_id":"","url":"https://api.github.com/users/ripple","html_url":"https://github.com/ripple","followers_url":"https://api.github.com/users/ripple/followers","following_url":"https://api.github.com/users/ripple/following{/other_user}","gists_url":"https://api.github.com/users/ripple/gists{/gist_id}","starred_url":"https://api.github.com/users/ripple/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ripple/subscriptions","organizations_url":"https://api.github.com/users/ripple/orgs","repos_url":"https://api.github.com/users/ripple/repos","events_url":"https://api.github.com/users/ripple/events{/privacy}","received_events_url":"https://api.github.com/users/ripple/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/ripple/rippled","description":"Decentralized cryptocurrency blockchain daemon implementing the Ripple Consensus Ledger in C++","fork":false,"url":"https://api.github.com/repos/ripple/rippled","forks_url":"https://api.github.com/repos/ripple/rippled/forks","keys_url":"https://api.github.com/repos/ripple/rippled/keys{/key_id}","collaborators_url":"https://api.github.com/repos/ripple/rippled/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/ripple/rippled/teams","hooks_url":"https://api.github.com/repos/ripple/rippled/hooks","issue_events_url":"https://api.github.com/repos/ripple/rippled/issues/events{/number}","events_url":"https://api.github.com/repos/ripple/rippled/events","assignees_url":"https://api.github.com/repos/ripple/rippled/assignees{/user}","branches_url":"https://api.github.com/repos/ripple/rippled/branches{/branch}","tags_url":"https://api.github.com/repos/ripple/rippled/tags","blobs_url":"https://api.github.com/repos/ripple/rippled/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/ripple/rippled/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/ripple/rippled/git/refs{/sha}","trees_url":"https://api.github.com/repos/ripple/rippled/git/trees{/sha}","statuses_url":"https://api.github.com/repos/ripple/rippled/statuses/{sha}","languages_url":"https://api.github.com/repos/ripple/rippled/languages","stargazers_url":"https://api.github.com/repos/ripple/rippled/stargazers","contributors_url":"https://api.github.com/repos/ripple/rippled/contributors","subscribers_url":"https://api.github.com/repos/ripple/rippled/subscribers","subscription_url":"https://api.github.com/repos/ripple/rippled/subscription","commits_url":"https://api.github.com/repos/ripple/rippled/commits{/sha}","git_commits_url":"https://api.github.com/repos/ripple/rippled/git/commits{/sha}","comments_url":"https://api.github.com/repos/ripple/rippled/comments{/number}","issue_comment_url":"https://api.github.com/repos/ripple/rippled/issues/comments{/number}","contents_url":"https://api.github.com/repos/ripple/rippled/contents/{+path}","compare_url":"https://api.github.com/repos/ripple/rippled/compare/{base}...{head}","merges_url":"https://api.github.com/repos/ripple/rippled/merges","archive_url":"https://api.github.com/repos/ripple/rippled/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/ripple/rippled/downloads","issues_url":"https://api.github.com/repos/ripple/rippled/issues{/number}","pulls_url":"https://api.github.com/repos/ripple/rippled/pulls{/number}","milestones_url":"https://api.github.com/repos/ripple/rippled/milestones{/number}","notifications_url":"https://api.github.com/repos/ripple/rippled/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/ripple/rippled/labels{/name}","releases_url":"https://api.github.com/repos/ripple/rippled/releases{/id}","deployments_url":"https://api.github.com/repos/ripple/rippled/deployments","created_at":"2011-11-07T04:40:15Z","updated_at":"2016-10-31T19:58:12Z","pushed_at":"2016-11-01T20:15:55Z","git_url":"git://github.com/ripple/rippled.git","ssh_url":"git@github.com:ripple/rippled.git","clone_url":"https://github.com/ripple/rippled.git","svn_url":"https://github.com/ripple/rippled","homepage":"https://ripple.com","size":132394,"stargazers_count":1166,"watchers_count":1166,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":361,"mirror_url":null,"open_issues_count":119,"forks":361,"open_issues":119,"watchers":1166,"default_branch":"develop"}},"_links":{"self":{"href":"https://api.github.com/repos/ripple/rippled/pulls/1884"},"html":{"href":"https://github.com/ripple/rippled/pull/1884"},"issue":{"href":"https://api.github.com/repos/ripple/rippled/issues/1884"},"comments":{"href":"https://api.github.com/repos/ripple/rippled/issues/1884/comments"},"review_comments":{"href":"https://api.github.com/repos/ripple/rippled/pulls/1884/comments"},"review_comment":{"href":"https://api.github.com/repos/ripple/rippled/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/ripple/rippled/pulls/1884/commits"},"statuses":{"href":"https://api.github.com/repos/ripple/rippled/statuses/50a36fcb5cd3b904cf01bef9e09d93f71f73b8f1"}}}}
{"actor":{"display_login":"vinniefalco"}}