{"action":"created","comment":{"url":"https://api.github.com/repos/chapel-lang/chapel/pulls/comments/51660840","id":51660840,"diff_hunk":"@@ -209,35 +223,44 @@ static FnSymbol* function_exists(const char* name,\n }\n \n \n+static void fixup_getter(AggregateType* ct, Symbol *field,","path":"compiler/passes/buildDefaultFunctions.cpp","position":60,"original_position":60,"commit_id":"455d6972eeb076fb627e4bb10ce78934e4e46f98","original_commit_id":"455d6972eeb076fb627e4bb10ce78934e4e46f98","user":{"login":"vasslitvinov","id":8039635,"avatar_url":"https://avatars.githubusercontent.com/u/8039635?v=3","gravatar_id":"","url":"https://api.github.com/users/vasslitvinov","html_url":"https://github.com/vasslitvinov","followers_url":"https://api.github.com/users/vasslitvinov/followers","following_url":"https://api.github.com/users/vasslitvinov/following{/other_user}","gists_url":"https://api.github.com/users/vasslitvinov/gists{/gist_id}","starred_url":"https://api.github.com/users/vasslitvinov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vasslitvinov/subscriptions","organizations_url":"https://api.github.com/users/vasslitvinov/orgs","repos_url":"https://api.github.com/users/vasslitvinov/repos","events_url":"https://api.github.com/users/vasslitvinov/events{/privacy}","received_events_url":"https://api.github.com/users/vasslitvinov/received_events","type":"User","site_admin":false},"body":"Let's call it \"fixup_accessor\".","created_at":"2016-02-03T00:26:42Z","updated_at":"2016-02-03T00:26:42Z","html_url":"https://github.com/chapel-lang/chapel/pull/3232#discussion_r51660840","pull_request_url":"https://api.github.com/repos/chapel-lang/chapel/pulls/3232","_links":{"self":{"href":"https://api.github.com/repos/chapel-lang/chapel/pulls/comments/51660840"},"html":{"href":"https://github.com/chapel-lang/chapel/pull/3232#discussion_r51660840"},"pull_request":{"href":"https://api.github.com/repos/chapel-lang/chapel/pulls/3232"}}},"pull_request":{"url":"https://api.github.com/repos/chapel-lang/chapel/pulls/3232","id":57915906,"html_url":"https://github.com/chapel-lang/chapel/pull/3232","diff_url":"https://github.com/chapel-lang/chapel/pull/3232.diff","patch_url":"https://github.com/chapel-lang/chapel/pull/3232.patch","issue_url":"https://api.github.com/repos/chapel-lang/chapel/issues/3232","number":3232,"state":"open","locked":false,"title":"Ref return change","user":{"login":"mppf","id":3653132,"avatar_url":"https://avatars.githubusercontent.com/u/3653132?v=3","gravatar_id":"","url":"https://api.github.com/users/mppf","html_url":"https://github.com/mppf","followers_url":"https://api.github.com/users/mppf/followers","following_url":"https://api.github.com/users/mppf/following{/other_user}","gists_url":"https://api.github.com/users/mppf/gists{/gist_id}","starred_url":"https://api.github.com/users/mppf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mppf/subscriptions","organizations_url":"https://api.github.com/users/mppf/orgs","repos_url":"https://api.github.com/users/mppf/repos","events_url":"https://api.github.com/users/mppf/events{/privacy}","received_events_url":"https://api.github.com/users/mppf/received_events","type":"User","site_admin":false},"body":"This PR removes the setter param and instead allows two otherwise\r\nambiguous functions where one has 'ref' and the other has default or\r\n'const ref' return intent. As before, with the setter param, the compiler\r\nwill choose between these two functions based on usage. In addition, this\r\nPR adds initial support for a 'const ref' return intent.\r\n\r\n### Language change examples\r\n\r\nThis example:\r\n\r\n    var globalInt : int;\r\n\r\n    proc returnRef1() ref {\r\n      if setter then {\r\n        return globalInt;\r\n      } else {\r\n        return someFunction();\r\n      }\r\n    }\r\n\r\n    returnRef1() = 1;       // resolves to setter=true\r\n    writeln(returnRef1());  // resolves to setter=false\r\n\r\nbecomes:\r\n\r\n    proc returnRef2() ref\r\n      return globalInt;\r\n    }\r\n\r\n    proc returnRef2()\r\n      return someFunction();\r\n    }\r\n\r\n\r\n    // resolves to 'ref' return intent version\r\n    returnRef2() = 1;\r\n    // resolves to default/const ref return intent version\r\n    writeln(returnRef2());\r\n\r\nand similarly, the 'const ref' return intent can be used:\r\n\r\n    proc returnRef3() ref\r\n      return globalInt;\r\n    }\r\n\r\n    proc returnRef3() const ref\r\n      return defaultValue;\r\n    }\r\n\r\nLastly, these semantics allow a local variable to be returned\r\nby value in the getter as happens today:\r\n\r\n    proc returnRef4() ref\r\n      return globalInt;\r\n    }\r\n\r\n    proc returnRef4()\r\n      var x = 10;\r\n      return x;\r\n    }\r\n\r\n\r\n### Advantages to this approach:\r\n\r\n* Avoids generating 2 versions of every ref return intent function\r\n* Allows users to use 'ref' or 'const ref' as manual performance optimization\r\n  to remove object copies. Being able to do such things is part of the\r\n  multi resolution design goal.\r\n* Makes 'ref' return intent mean something closer to 'ref' arg intent\r\n* Allows for a sensible 'const ref' return intent without it needing to\r\n  be wildly different from the 'ref' return intent\r\n* Retires special behavior for 'setter' variable\r\n* Allows users/module code to choose between 'ref', 'const ref',\r\n  and 'by value' return for the rvalue version. Allows policy decisions\r\n  in module code that are performance optimizations (e.g.\r\n  we might find returning int array elements by value is more\r\n  efficient than by 'const ref').\r\n\r\n\r\n### Implementation\r\n\r\nIn order to support the full variety of possibilities, and based on discussions\r\nwith @bradcray , I changed the implementation for the setter-getter pair to be\r\ntriggered by an otherwise ambiguous function resolution. That way, the getter\r\ncould have an optional argument that is not present in the setter (for\r\nexample).\r\n\r\nSince we detect the setter-getter pair in resolveNormalCall(), we needed a way\r\nto record both individual calls as possibilities for cullOverReferences() to\r\nselect. If we continued to store this information in each FnSymbol (as the\r\nprevious implementation did), we would not support getters and setters with\r\nslightly different arguments (e.g. an optional argument).\r\n\r\nI added a new AST element, ContextCallExpr, as the way to record both calls.\r\nSuch AST elements only exist during resolution passes - they are created in\r\nresolve and consumed in cullOverReferences. In order to avoid needing to modify\r\nthe bulk of the code in function resolution, I adjusted isCallExpr() and\r\ntoCallExpr() to behave in a special manner with a ContextCallExpr. isCallExpr()\r\nreturns true and toCallExpr returns the designated call (which is the ref\r\nversion). As with the previous implementation, cullOverReferences performs the\r\nnecessary AST transformations to go from the ref return version to a value\r\nreturn version - so most of the other resolution code can pretend it is just\r\nworking with the ref version of the CallExpr instead of a ContextCallExpr.\r\n\r\nPassed full local testing.\r\nPassed GASNet-everything testing for release/examples.","created_at":"2016-02-01T23:13:20Z","updated_at":"2016-02-03T00:26:42Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b31ba31bd92f0ebd03c6d988ace701dee80e352d","assignee":{"login":"vasslitvinov","id":8039635,"avatar_url":"https://avatars.githubusercontent.com/u/8039635?v=3","gravatar_id":"","url":"https://api.github.com/users/vasslitvinov","html_url":"https://github.com/vasslitvinov","followers_url":"https://api.github.com/users/vasslitvinov/followers","following_url":"https://api.github.com/users/vasslitvinov/following{/other_user}","gists_url":"https://api.github.com/users/vasslitvinov/gists{/gist_id}","starred_url":"https://api.github.com/users/vasslitvinov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vasslitvinov/subscriptions","organizations_url":"https://api.github.com/users/vasslitvinov/orgs","repos_url":"https://api.github.com/users/vasslitvinov/repos","events_url":"https://api.github.com/users/vasslitvinov/events{/privacy}","received_events_url":"https://api.github.com/users/vasslitvinov/received_events","type":"User","site_admin":false},"milestone":null,"commits_url":"https://api.github.com/repos/chapel-lang/chapel/pulls/3232/commits","review_comments_url":"https://api.github.com/repos/chapel-lang/chapel/pulls/3232/comments","review_comment_url":"https://api.github.com/repos/chapel-lang/chapel/pulls/comments{/number}","comments_url":"https://api.github.com/repos/chapel-lang/chapel/issues/3232/comments","statuses_url":"https://api.github.com/repos/chapel-lang/chapel/statuses/455d6972eeb076fb627e4bb10ce78934e4e46f98","head":{"label":"mppf:ref-return-change","ref":"ref-return-change","sha":"455d6972eeb076fb627e4bb10ce78934e4e46f98","user":{"login":"mppf","id":3653132,"avatar_url":"https://avatars.githubusercontent.com/u/3653132?v=3","gravatar_id":"","url":"https://api.github.com/users/mppf","html_url":"https://github.com/mppf","followers_url":"https://api.github.com/users/mppf/followers","following_url":"https://api.github.com/users/mppf/following{/other_user}","gists_url":"https://api.github.com/users/mppf/gists{/gist_id}","starred_url":"https://api.github.com/users/mppf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mppf/subscriptions","organizations_url":"https://api.github.com/users/mppf/orgs","repos_url":"https://api.github.com/users/mppf/repos","events_url":"https://api.github.com/users/mppf/events{/privacy}","received_events_url":"https://api.github.com/users/mppf/received_events","type":"User","site_admin":false},"repo":{"id":22106313,"name":"chapel","full_name":"mppf/chapel","owner":{"login":"mppf","id":3653132,"avatar_url":"https://avatars.githubusercontent.com/u/3653132?v=3","gravatar_id":"","url":"https://api.github.com/users/mppf","html_url":"https://github.com/mppf","followers_url":"https://api.github.com/users/mppf/followers","following_url":"https://api.github.com/users/mppf/following{/other_user}","gists_url":"https://api.github.com/users/mppf/gists{/gist_id}","starred_url":"https://api.github.com/users/mppf/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mppf/subscriptions","organizations_url":"https://api.github.com/users/mppf/orgs","repos_url":"https://api.github.com/users/mppf/repos","events_url":"https://api.github.com/users/mppf/events{/privacy}","received_events_url":"https://api.github.com/users/mppf/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/mppf/chapel","description":"a Productive Parallel Programming Language","fork":true,"url":"https://api.github.com/repos/mppf/chapel","forks_url":"https://api.github.com/repos/mppf/chapel/forks","keys_url":"https://api.github.com/repos/mppf/chapel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/mppf/chapel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/mppf/chapel/teams","hooks_url":"https://api.github.com/repos/mppf/chapel/hooks","issue_events_url":"https://api.github.com/repos/mppf/chapel/issues/events{/number}","events_url":"https://api.github.com/repos/mppf/chapel/events","assignees_url":"https://api.github.com/repos/mppf/chapel/assignees{/user}","branches_url":"https://api.github.com/repos/mppf/chapel/branches{/branch}","tags_url":"https://api.github.com/repos/mppf/chapel/tags","blobs_url":"https://api.github.com/repos/mppf/chapel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/mppf/chapel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/mppf/chapel/git/refs{/sha}","trees_url":"https://api.github.com/repos/mppf/chapel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/mppf/chapel/statuses/{sha}","languages_url":"https://api.github.com/repos/mppf/chapel/languages","stargazers_url":"https://api.github.com/repos/mppf/chapel/stargazers","contributors_url":"https://api.github.com/repos/mppf/chapel/contributors","subscribers_url":"https://api.github.com/repos/mppf/chapel/subscribers","subscription_url":"https://api.github.com/repos/mppf/chapel/subscription","commits_url":"https://api.github.com/repos/mppf/chapel/commits{/sha}","git_commits_url":"https://api.github.com/repos/mppf/chapel/git/commits{/sha}","comments_url":"https://api.github.com/repos/mppf/chapel/comments{/number}","issue_comment_url":"https://api.github.com/repos/mppf/chapel/issues/comments{/number}","contents_url":"https://api.github.com/repos/mppf/chapel/contents/{+path}","compare_url":"https://api.github.com/repos/mppf/chapel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/mppf/chapel/merges","archive_url":"https://api.github.com/repos/mppf/chapel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/mppf/chapel/downloads","issues_url":"https://api.github.com/repos/mppf/chapel/issues{/number}","pulls_url":"https://api.github.com/repos/mppf/chapel/pulls{/number}","milestones_url":"https://api.github.com/repos/mppf/chapel/milestones{/number}","notifications_url":"https://api.github.com/repos/mppf/chapel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/mppf/chapel/labels{/name}","releases_url":"https://api.github.com/repos/mppf/chapel/releases{/id}","deployments_url":"https://api.github.com/repos/mppf/chapel/deployments","created_at":"2014-07-22T14:05:45Z","updated_at":"2016-01-11T15:01:10Z","pushed_at":"2016-02-02T22:24:19Z","git_url":"git://github.com/mppf/chapel.git","ssh_url":"git@github.com:mppf/chapel.git","clone_url":"https://github.com/mppf/chapel.git","svn_url":"https://github.com/mppf/chapel","homepage":"http://chapel.cray.com/","size":432626,"stargazers_count":1,"watchers_count":1,"language":"Chapel","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":1,"default_branch":"master"}},"base":{"label":"chapel-lang:master","ref":"master","sha":"4e33c821eb2d6d030343e722fe8f7c3b1831530b","user":{"login":"chapel-lang","id":7597261,"avatar_url":"https://avatars.githubusercontent.com/u/7597261?v=3","gravatar_id":"","url":"https://api.github.com/users/chapel-lang","html_url":"https://github.com/chapel-lang","followers_url":"https://api.github.com/users/chapel-lang/followers","following_url":"https://api.github.com/users/chapel-lang/following{/other_user}","gists_url":"https://api.github.com/users/chapel-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/chapel-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chapel-lang/subscriptions","organizations_url":"https://api.github.com/users/chapel-lang/orgs","repos_url":"https://api.github.com/users/chapel-lang/repos","events_url":"https://api.github.com/users/chapel-lang/events{/privacy}","received_events_url":"https://api.github.com/users/chapel-lang/received_events","type":"Organization","site_admin":false},"repo":{"id":21663285,"name":"chapel","full_name":"chapel-lang/chapel","owner":{"login":"chapel-lang","id":7597261,"avatar_url":"https://avatars.githubusercontent.com/u/7597261?v=3","gravatar_id":"","url":"https://api.github.com/users/chapel-lang","html_url":"https://github.com/chapel-lang","followers_url":"https://api.github.com/users/chapel-lang/followers","following_url":"https://api.github.com/users/chapel-lang/following{/other_user}","gists_url":"https://api.github.com/users/chapel-lang/gists{/gist_id}","starred_url":"https://api.github.com/users/chapel-lang/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chapel-lang/subscriptions","organizations_url":"https://api.github.com/users/chapel-lang/orgs","repos_url":"https://api.github.com/users/chapel-lang/repos","events_url":"https://api.github.com/users/chapel-lang/events{/privacy}","received_events_url":"https://api.github.com/users/chapel-lang/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/chapel-lang/chapel","description":"a Productive Parallel Programming Language","fork":false,"url":"https://api.github.com/repos/chapel-lang/chapel","forks_url":"https://api.github.com/repos/chapel-lang/chapel/forks","keys_url":"https://api.github.com/repos/chapel-lang/chapel/keys{/key_id}","collaborators_url":"https://api.github.com/repos/chapel-lang/chapel/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/chapel-lang/chapel/teams","hooks_url":"https://api.github.com/repos/chapel-lang/chapel/hooks","issue_events_url":"https://api.github.com/repos/chapel-lang/chapel/issues/events{/number}","events_url":"https://api.github.com/repos/chapel-lang/chapel/events","assignees_url":"https://api.github.com/repos/chapel-lang/chapel/assignees{/user}","branches_url":"https://api.github.com/repos/chapel-lang/chapel/branches{/branch}","tags_url":"https://api.github.com/repos/chapel-lang/chapel/tags","blobs_url":"https://api.github.com/repos/chapel-lang/chapel/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/chapel-lang/chapel/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/chapel-lang/chapel/git/refs{/sha}","trees_url":"https://api.github.com/repos/chapel-lang/chapel/git/trees{/sha}","statuses_url":"https://api.github.com/repos/chapel-lang/chapel/statuses/{sha}","languages_url":"https://api.github.com/repos/chapel-lang/chapel/languages","stargazers_url":"https://api.github.com/repos/chapel-lang/chapel/stargazers","contributors_url":"https://api.github.com/repos/chapel-lang/chapel/contributors","subscribers_url":"https://api.github.com/repos/chapel-lang/chapel/subscribers","subscription_url":"https://api.github.com/repos/chapel-lang/chapel/subscription","commits_url":"https://api.github.com/repos/chapel-lang/chapel/commits{/sha}","git_commits_url":"https://api.github.com/repos/chapel-lang/chapel/git/commits{/sha}","comments_url":"https://api.github.com/repos/chapel-lang/chapel/comments{/number}","issue_comment_url":"https://api.github.com/repos/chapel-lang/chapel/issues/comments{/number}","contents_url":"https://api.github.com/repos/chapel-lang/chapel/contents/{+path}","compare_url":"https://api.github.com/repos/chapel-lang/chapel/compare/{base}...{head}","merges_url":"https://api.github.com/repos/chapel-lang/chapel/merges","archive_url":"https://api.github.com/repos/chapel-lang/chapel/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/chapel-lang/chapel/downloads","issues_url":"https://api.github.com/repos/chapel-lang/chapel/issues{/number}","pulls_url":"https://api.github.com/repos/chapel-lang/chapel/pulls{/number}","milestones_url":"https://api.github.com/repos/chapel-lang/chapel/milestones{/number}","notifications_url":"https://api.github.com/repos/chapel-lang/chapel/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/chapel-lang/chapel/labels{/name}","releases_url":"https://api.github.com/repos/chapel-lang/chapel/releases{/id}","deployments_url":"https://api.github.com/repos/chapel-lang/chapel/deployments","created_at":"2014-07-09T18:15:54Z","updated_at":"2016-02-02T06:09:43Z","pushed_at":"2016-02-02T22:24:20Z","git_url":"git://github.com/chapel-lang/chapel.git","ssh_url":"git@github.com:chapel-lang/chapel.git","clone_url":"https://github.com/chapel-lang/chapel.git","svn_url":"https://github.com/chapel-lang/chapel","homepage":"http://chapel.cray.com/","size":439620,"stargazers_count":199,"watchers_count":199,"language":"Chapel","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":66,"mirror_url":null,"open_issues_count":7,"forks":66,"open_issues":7,"watchers":199,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/chapel-lang/chapel/pulls/3232"},"html":{"href":"https://github.com/chapel-lang/chapel/pull/3232"},"issue":{"href":"https://api.github.com/repos/chapel-lang/chapel/issues/3232"},"comments":{"href":"https://api.github.com/repos/chapel-lang/chapel/issues/3232/comments"},"review_comments":{"href":"https://api.github.com/repos/chapel-lang/chapel/pulls/3232/comments"},"review_comment":{"href":"https://api.github.com/repos/chapel-lang/chapel/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/chapel-lang/chapel/pulls/3232/commits"},"statuses":{"href":"https://api.github.com/repos/chapel-lang/chapel/statuses/455d6972eeb076fb627e4bb10ce78934e4e46f98"}}}}