{"action":"created","issue":{"url":"https://api.github.com/repos/qorelanguage/qore/issues/1179","repository_url":"https://api.github.com/repos/qorelanguage/qore","labels_url":"https://api.github.com/repos/qorelanguage/qore/issues/1179/labels{/name}","comments_url":"https://api.github.com/repos/qorelanguage/qore/issues/1179/comments","events_url":"https://api.github.com/repos/qorelanguage/qore/issues/1179/events","html_url":"https://github.com/qorelanguage/qore/issues/1179","id":171970472,"number":1179,"title":"Qore needs stronger class encapsulation","user":{"login":"davidnich","id":13432105,"avatar_url":"https://avatars.githubusercontent.com/u/13432105?v=3","gravatar_id":"","url":"https://api.github.com/users/davidnich","html_url":"https://github.com/davidnich","followers_url":"https://api.github.com/users/davidnich/followers","following_url":"https://api.github.com/users/davidnich/following{/other_user}","gists_url":"https://api.github.com/users/davidnich/gists{/gist_id}","starred_url":"https://api.github.com/users/davidnich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidnich/subscriptions","organizations_url":"https://api.github.com/users/davidnich/orgs","repos_url":"https://api.github.com/users/davidnich/repos","events_url":"https://api.github.com/users/davidnich/events{/privacy}","received_events_url":"https://api.github.com/users/davidnich/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/qorelanguage/qore/labels/c++","name":"c++","color":"6b0075"},{"url":"https://api.github.com/repos/qorelanguage/qore/labels/feature","name":"feature","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":{"url":"https://api.github.com/repos/qorelanguage/qore/milestones/5","html_url":"https://github.com/qorelanguage/qore/milestones/0.8.13","labels_url":"https://api.github.com/repos/qorelanguage/qore/milestones/5/labels","id":1824541,"number":5,"title":"0.8.13","description":"","creator":{"login":"tethal","id":2562437,"avatar_url":"https://avatars.githubusercontent.com/u/2562437?v=3","gravatar_id":"","url":"https://api.github.com/users/tethal","html_url":"https://github.com/tethal","followers_url":"https://api.github.com/users/tethal/followers","following_url":"https://api.github.com/users/tethal/following{/other_user}","gists_url":"https://api.github.com/users/tethal/gists{/gist_id}","starred_url":"https://api.github.com/users/tethal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tethal/subscriptions","organizations_url":"https://api.github.com/users/tethal/orgs","repos_url":"https://api.github.com/users/tethal/repos","events_url":"https://api.github.com/users/tethal/events{/privacy}","received_events_url":"https://api.github.com/users/tethal/received_events","type":"User","site_admin":false},"open_issues":23,"closed_issues":28,"state":"open","created_at":"2016-06-13T21:06:32Z","updated_at":"2016-08-26T16:16:54Z","due_on":null,"closed_at":null},"comments":19,"created_at":"2016-08-18T18:37:36Z","updated_at":"2016-08-27T05:18:25Z","closed_at":null,"body":"currently \"private\" members and methods are available to any subclass (unlike \"private\" in c++ for example, and even weaker than \"protected\" in c++).\r\n\r\nthis means that there is no real private implementation possible in Qore and therefore any changes to a class's implementation can cause compatibility issues.\r\n\r\nto prohibit this, Qore needs a stronger form of encapsulation that allows classes to have real private implementations to isolate private members and methods from being accessed outside the class itself (so also not from any child classes in the hierarchy) and therefore enable more flexibility in making changes that don't break backwards compatibility.\r\n\r\nCurrently I would propose the keyword `local` - ex:\r\n\r\n```Perl\r\nclass X {\r\n    private {\r\n        # this member can be accessed from anywhere in the current class hierarchy\r\n        int x;\r\n    }\r\n\r\n    local {\r\n        # this member can only be accessed from within the current class\r\n        string status;\r\n    }\r\n\r\n    # this method can be accessed from anywhere in the current class hierarchy\r\n    private int methodA() {\r\n        return 2;\r\n    }\r\n\r\n    # this method can only be accessed from within the current class\r\n    local int methodB() {\r\n        return 1;\r\n    }\r\n}\r\n```\r\n\r\nAbove, `local` would indicate members and methods that could only be accessed from inside the class.\r\n\r\nUnlike `private` and `public` members and methods, `local` members and methods could be redefined in child classes with the same names, which allows for more encapsulation and flexibility. \r\n\r\nThis is a \"feature\" but also a design bug in Qore - this issue is meant to resolve this design bug."},"comment":{"url":"https://api.github.com/repos/qorelanguage/qore/issues/comments/242897081","html_url":"https://github.com/qorelanguage/qore/issues/1179#issuecomment-242897081","issue_url":"https://api.github.com/repos/qorelanguage/qore/issues/1179","id":242897081,"user":{"login":"davidnich","id":13432105,"avatar_url":"https://avatars.githubusercontent.com/u/13432105?v=3","gravatar_id":"","url":"https://api.github.com/users/davidnich","html_url":"https://github.com/davidnich","followers_url":"https://api.github.com/users/davidnich/followers","following_url":"https://api.github.com/users/davidnich/following{/other_user}","gists_url":"https://api.github.com/users/davidnich/gists{/gist_id}","starred_url":"https://api.github.com/users/davidnich/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/davidnich/subscriptions","organizations_url":"https://api.github.com/users/davidnich/orgs","repos_url":"https://api.github.com/users/davidnich/repos","events_url":"https://api.github.com/users/davidnich/events{/privacy}","received_events_url":"https://api.github.com/users/davidnich/received_events","type":"User","site_admin":false},"created_at":"2016-08-27T05:18:25Z","updated_at":"2016-08-27T05:18:25Z","body":"I did some trial implementations of just the scanner/parser stuff, both `internal` and `local` cause compatibility issues.  `private(local)` and `private(hierarchy)` cause none - based on this - the ability to introduce a new feature without causing any backwards compatibility issues - I prefer `private(local)` and `private(hierarchy)` for this"}}
{"actor":{"display_login":"davidnich"}}