{"action":"created","comment":{"url":"https://api.github.com/repos/D-Programming-Language/dlang.org/pulls/comments/38261724","id":38261724,"diff_hunk":"@@ -121,14 +121,61 @@ int foo();\n \n $(H4 $(LNAME2 pure-functions, Pure Functions))\n \n-        $(P Pure functions are functions which cannot access global or static, mutable\n-        state save through their arguments. This can enable optimizations based on the fact\n-        that a pure function is guaranteed to mutate nothing which isn't passed to it,\n+    $(P Pure functions are functions which cannot directly access global or static\n+        mutable state. It guarantees that a pure function call won't modify any\n+        invisible places from the caller side.\n+    )\n+\n+    $(P Different from some other functional programming languages, D's pure\n+        function allows modification of caller side state through its mutable\n+        parameters.\n+\n+        ---\n+        pure int foo(int[] arr) { arr[] += 1; return arr.length; }\n+        int[] a = [1, 2, 3];\n+        foo(a);\n+        assert(a == [2, 3, 4]);\n+        ---\n+\n+        The minimum guarantee of \"pure\" is called \"weak purity\". It's designed to\n+        increase modularity of functions.\n+    )\n+\n+    $(P To control mutations, D has the $(D immutable) type qualifier. If all of\n+        a $(D pure) function's parameters are $(D immutable) or copied values\n+        without any indirections, it can guarantee that the pure function has\n+        no side effects.\n+    )\n+\n+        ---\n+        struct S { double x; }\n+        pure int foo(immutable(int)[] arr, int num, S val)\n+        {\n+            //arr[num] = 1; // compile error\n+            num = 2;        // has no side effect to the caller side\n+            val.x = 3.14;   // ditto\n+            return arr.length;\n+        }\n+        ---\n+\n+    $(P The maximum guarantee of \"pure\" is called \"strong purity\". It can enable","path":"function.dd","position":44,"original_position":44,"commit_id":"ae4c950994e7dbc0466f8a1c9b4c08fe7ec228e3","original_commit_id":"ae4c950994e7dbc0466f8a1c9b4c08fe7ec228e3","user":{"login":"9rnsr","id":254394,"avatar_url":"https://avatars.githubusercontent.com/u/254394?v=3","gravatar_id":"","url":"https://api.github.com/users/9rnsr","html_url":"https://github.com/9rnsr","followers_url":"https://api.github.com/users/9rnsr/followers","following_url":"https://api.github.com/users/9rnsr/following{/other_user}","gists_url":"https://api.github.com/users/9rnsr/gists{/gist_id}","starred_url":"https://api.github.com/users/9rnsr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/9rnsr/subscriptions","organizations_url":"https://api.github.com/users/9rnsr/orgs","repos_url":"https://api.github.com/users/9rnsr/repos","events_url":"https://api.github.com/users/9rnsr/events{/privacy}","received_events_url":"https://api.github.com/users/9rnsr/received_events","type":"User","site_admin":false},"body":"> All the implications of pure can be explained without it\r\n\r\nAt least I cannot explain the concept by English without the terms weak/strong purity.","created_at":"2015-08-29T12:46:21Z","updated_at":"2015-08-29T12:46:21Z","html_url":"https://github.com/D-Programming-Language/dlang.org/pull/1040#discussion_r38261724","pull_request_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/pulls/1040","_links":{"self":{"href":"https://api.github.com/repos/D-Programming-Language/dlang.org/pulls/comments/38261724"},"html":{"href":"https://github.com/D-Programming-Language/dlang.org/pull/1040#discussion_r38261724"},"pull_request":{"href":"https://api.github.com/repos/D-Programming-Language/dlang.org/pulls/1040"}}},"pull_request":{"url":"https://api.github.com/repos/D-Programming-Language/dlang.org/pulls/1040","id":40468635,"html_url":"https://github.com/D-Programming-Language/dlang.org/pull/1040","diff_url":"https://github.com/D-Programming-Language/dlang.org/pull/1040.diff","patch_url":"https://github.com/D-Programming-Language/dlang.org/pull/1040.patch","issue_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/issues/1040","number":1040,"state":"open","locked":false,"title":"Update Core Language specification","user":{"login":"9rnsr","id":254394,"avatar_url":"https://avatars.githubusercontent.com/u/254394?v=3","gravatar_id":"","url":"https://api.github.com/users/9rnsr","html_url":"https://github.com/9rnsr","followers_url":"https://api.github.com/users/9rnsr/followers","following_url":"https://api.github.com/users/9rnsr/following{/other_user}","gists_url":"https://api.github.com/users/9rnsr/gists{/gist_id}","starred_url":"https://api.github.com/users/9rnsr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/9rnsr/subscriptions","organizations_url":"https://api.github.com/users/9rnsr/orgs","repos_url":"https://api.github.com/users/9rnsr/repos","events_url":"https://api.github.com/users/9rnsr/events{/privacy}","received_events_url":"https://api.github.com/users/9rnsr/received_events","type":"User","site_admin":false},"body":"Points:\r\n- Update outdated descriptions.\r\n- Follow the latest compiler behaviors.\r\n- Add inter-page links to associate related sections.","created_at":"2015-07-21T15:14:52Z","updated_at":"2015-08-29T12:46:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"bf8ed3b59c1f8eabe8004a8492af8d1eaf5c0b1f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/pulls/1040/commits","review_comments_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/pulls/1040/comments","review_comment_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/pulls/comments{/number}","comments_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/issues/1040/comments","statuses_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/statuses/ae4c950994e7dbc0466f8a1c9b4c08fe7ec228e3","head":{"label":"9rnsr:update_spec","ref":"update_spec","sha":"ae4c950994e7dbc0466f8a1c9b4c08fe7ec228e3","user":{"login":"9rnsr","id":254394,"avatar_url":"https://avatars.githubusercontent.com/u/254394?v=3","gravatar_id":"","url":"https://api.github.com/users/9rnsr","html_url":"https://github.com/9rnsr","followers_url":"https://api.github.com/users/9rnsr/followers","following_url":"https://api.github.com/users/9rnsr/following{/other_user}","gists_url":"https://api.github.com/users/9rnsr/gists{/gist_id}","starred_url":"https://api.github.com/users/9rnsr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/9rnsr/subscriptions","organizations_url":"https://api.github.com/users/9rnsr/orgs","repos_url":"https://api.github.com/users/9rnsr/repos","events_url":"https://api.github.com/users/9rnsr/events{/privacy}","received_events_url":"https://api.github.com/users/9rnsr/received_events","type":"User","site_admin":false},"repo":{"id":1992198,"name":"dlang.org","full_name":"9rnsr/dlang.org","owner":{"login":"9rnsr","id":254394,"avatar_url":"https://avatars.githubusercontent.com/u/254394?v=3","gravatar_id":"","url":"https://api.github.com/users/9rnsr","html_url":"https://github.com/9rnsr","followers_url":"https://api.github.com/users/9rnsr/followers","following_url":"https://api.github.com/users/9rnsr/following{/other_user}","gists_url":"https://api.github.com/users/9rnsr/gists{/gist_id}","starred_url":"https://api.github.com/users/9rnsr/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/9rnsr/subscriptions","organizations_url":"https://api.github.com/users/9rnsr/orgs","repos_url":"https://api.github.com/users/9rnsr/repos","events_url":"https://api.github.com/users/9rnsr/events{/privacy}","received_events_url":"https://api.github.com/users/9rnsr/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/9rnsr/dlang.org","description":"Pages for the d-programming-language.org web site","fork":true,"url":"https://api.github.com/repos/9rnsr/dlang.org","forks_url":"https://api.github.com/repos/9rnsr/dlang.org/forks","keys_url":"https://api.github.com/repos/9rnsr/dlang.org/keys{/key_id}","collaborators_url":"https://api.github.com/repos/9rnsr/dlang.org/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/9rnsr/dlang.org/teams","hooks_url":"https://api.github.com/repos/9rnsr/dlang.org/hooks","issue_events_url":"https://api.github.com/repos/9rnsr/dlang.org/issues/events{/number}","events_url":"https://api.github.com/repos/9rnsr/dlang.org/events","assignees_url":"https://api.github.com/repos/9rnsr/dlang.org/assignees{/user}","branches_url":"https://api.github.com/repos/9rnsr/dlang.org/branches{/branch}","tags_url":"https://api.github.com/repos/9rnsr/dlang.org/tags","blobs_url":"https://api.github.com/repos/9rnsr/dlang.org/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/9rnsr/dlang.org/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/9rnsr/dlang.org/git/refs{/sha}","trees_url":"https://api.github.com/repos/9rnsr/dlang.org/git/trees{/sha}","statuses_url":"https://api.github.com/repos/9rnsr/dlang.org/statuses/{sha}","languages_url":"https://api.github.com/repos/9rnsr/dlang.org/languages","stargazers_url":"https://api.github.com/repos/9rnsr/dlang.org/stargazers","contributors_url":"https://api.github.com/repos/9rnsr/dlang.org/contributors","subscribers_url":"https://api.github.com/repos/9rnsr/dlang.org/subscribers","subscription_url":"https://api.github.com/repos/9rnsr/dlang.org/subscription","commits_url":"https://api.github.com/repos/9rnsr/dlang.org/commits{/sha}","git_commits_url":"https://api.github.com/repos/9rnsr/dlang.org/git/commits{/sha}","comments_url":"https://api.github.com/repos/9rnsr/dlang.org/comments{/number}","issue_comment_url":"https://api.github.com/repos/9rnsr/dlang.org/issues/comments{/number}","contents_url":"https://api.github.com/repos/9rnsr/dlang.org/contents/{+path}","compare_url":"https://api.github.com/repos/9rnsr/dlang.org/compare/{base}...{head}","merges_url":"https://api.github.com/repos/9rnsr/dlang.org/merges","archive_url":"https://api.github.com/repos/9rnsr/dlang.org/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/9rnsr/dlang.org/downloads","issues_url":"https://api.github.com/repos/9rnsr/dlang.org/issues{/number}","pulls_url":"https://api.github.com/repos/9rnsr/dlang.org/pulls{/number}","milestones_url":"https://api.github.com/repos/9rnsr/dlang.org/milestones{/number}","notifications_url":"https://api.github.com/repos/9rnsr/dlang.org/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/9rnsr/dlang.org/labels{/name}","releases_url":"https://api.github.com/repos/9rnsr/dlang.org/releases{/id}","created_at":"2011-07-03T19:21:36Z","updated_at":"2015-03-22T03:58:30Z","pushed_at":"2015-08-19T06:12:33Z","git_url":"git://github.com/9rnsr/dlang.org.git","ssh_url":"git@github.com:9rnsr/dlang.org.git","clone_url":"https://github.com/9rnsr/dlang.org.git","svn_url":"https://github.com/9rnsr/dlang.org","homepage":"dlang.org","size":11182,"stargazers_count":1,"watchers_count":1,"language":"CSS","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":1,"default_branch":"master"}},"base":{"label":"D-Programming-Language:master","ref":"master","sha":"eb9635f66087761793d863b836e3677b93b20289","user":{"login":"D-Programming-Language","id":565913,"avatar_url":"https://avatars.githubusercontent.com/u/565913?v=3","gravatar_id":"","url":"https://api.github.com/users/D-Programming-Language","html_url":"https://github.com/D-Programming-Language","followers_url":"https://api.github.com/users/D-Programming-Language/followers","following_url":"https://api.github.com/users/D-Programming-Language/following{/other_user}","gists_url":"https://api.github.com/users/D-Programming-Language/gists{/gist_id}","starred_url":"https://api.github.com/users/D-Programming-Language/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/D-Programming-Language/subscriptions","organizations_url":"https://api.github.com/users/D-Programming-Language/orgs","repos_url":"https://api.github.com/users/D-Programming-Language/repos","events_url":"https://api.github.com/users/D-Programming-Language/events{/privacy}","received_events_url":"https://api.github.com/users/D-Programming-Language/received_events","type":"Organization","site_admin":false},"repo":{"id":1257080,"name":"dlang.org","full_name":"D-Programming-Language/dlang.org","owner":{"login":"D-Programming-Language","id":565913,"avatar_url":"https://avatars.githubusercontent.com/u/565913?v=3","gravatar_id":"","url":"https://api.github.com/users/D-Programming-Language","html_url":"https://github.com/D-Programming-Language","followers_url":"https://api.github.com/users/D-Programming-Language/followers","following_url":"https://api.github.com/users/D-Programming-Language/following{/other_user}","gists_url":"https://api.github.com/users/D-Programming-Language/gists{/gist_id}","starred_url":"https://api.github.com/users/D-Programming-Language/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/D-Programming-Language/subscriptions","organizations_url":"https://api.github.com/users/D-Programming-Language/orgs","repos_url":"https://api.github.com/users/D-Programming-Language/repos","events_url":"https://api.github.com/users/D-Programming-Language/events{/privacy}","received_events_url":"https://api.github.com/users/D-Programming-Language/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/D-Programming-Language/dlang.org","description":"Pages for the dlang.org website, home of the D Programming Language","fork":false,"url":"https://api.github.com/repos/D-Programming-Language/dlang.org","forks_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/forks","keys_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/keys{/key_id}","collaborators_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/teams","hooks_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/hooks","issue_events_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/issues/events{/number}","events_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/events","assignees_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/assignees{/user}","branches_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/branches{/branch}","tags_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/tags","blobs_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/git/refs{/sha}","trees_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/git/trees{/sha}","statuses_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/statuses/{sha}","languages_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/languages","stargazers_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/stargazers","contributors_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/contributors","subscribers_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/subscribers","subscription_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/subscription","commits_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/commits{/sha}","git_commits_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/git/commits{/sha}","comments_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/comments{/number}","issue_comment_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/issues/comments{/number}","contents_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/contents/{+path}","compare_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/compare/{base}...{head}","merges_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/merges","archive_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/downloads","issues_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/issues{/number}","pulls_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/pulls{/number}","milestones_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/milestones{/number}","notifications_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/labels{/name}","releases_url":"https://api.github.com/repos/D-Programming-Language/dlang.org/releases{/id}","created_at":"2011-01-15T06:58:12Z","updated_at":"2015-08-12T07:14:39Z","pushed_at":"2015-08-28T15:30:20Z","git_url":"git://github.com/D-Programming-Language/dlang.org.git","ssh_url":"git@github.com:D-Programming-Language/dlang.org.git","clone_url":"https://github.com/D-Programming-Language/dlang.org.git","svn_url":"https://github.com/D-Programming-Language/dlang.org","homepage":"dlang.org","size":20163,"stargazers_count":169,"watchers_count":169,"language":"CSS","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":215,"mirror_url":null,"open_issues_count":15,"forks":215,"open_issues":15,"watchers":169,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/D-Programming-Language/dlang.org/pulls/1040"},"html":{"href":"https://github.com/D-Programming-Language/dlang.org/pull/1040"},"issue":{"href":"https://api.github.com/repos/D-Programming-Language/dlang.org/issues/1040"},"comments":{"href":"https://api.github.com/repos/D-Programming-Language/dlang.org/issues/1040/comments"},"review_comments":{"href":"https://api.github.com/repos/D-Programming-Language/dlang.org/pulls/1040/comments"},"review_comment":{"href":"https://api.github.com/repos/D-Programming-Language/dlang.org/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/D-Programming-Language/dlang.org/pulls/1040/commits"},"statuses":{"href":"https://api.github.com/repos/D-Programming-Language/dlang.org/statuses/ae4c950994e7dbc0466f8a1c9b4c08fe7ec228e3"}}}}