{"action":"created","issue":{"url":"https://api.github.com/repos/vlang/v/issues/64","repository_url":"https://api.github.com/repos/vlang/v","labels_url":"https://api.github.com/repos/vlang/v/issues/64/labels{/name}","comments_url":"https://api.github.com/repos/vlang/v/issues/64/comments","events_url":"https://api.github.com/repos/vlang/v/issues/64/events","html_url":"https://github.com/vlang/v/issues/64","id":429335714,"node_id":"MDU6SXNzdWU0MjkzMzU3MTQ=","number":64,"title":"Syntax for access modifiers","user":{"login":"medvednikov","id":687996,"node_id":"MDQ6VXNlcjY4Nzk5Ng==","avatar_url":"https://avatars2.githubusercontent.com/u/687996?v=4","gravatar_id":"","url":"https://api.github.com/users/medvednikov","html_url":"https://github.com/medvednikov","followers_url":"https://api.github.com/users/medvednikov/followers","following_url":"https://api.github.com/users/medvednikov/following{/other_user}","gists_url":"https://api.github.com/users/medvednikov/gists{/gist_id}","starred_url":"https://api.github.com/users/medvednikov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/medvednikov/subscriptions","organizations_url":"https://api.github.com/users/medvednikov/orgs","repos_url":"https://api.github.com/users/medvednikov/repos","events_url":"https://api.github.com/users/medvednikov/events{/privacy}","received_events_url":"https://api.github.com/users/medvednikov/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":40,"created_at":"2019-04-04T15:12:49Z","updated_at":"2019-04-28T08:23:51Z","closed_at":null,"author_association":"CONTRIBUTOR","body":"Here's what I currently have in mind:\r\n\r\n```\r\nmodule foo\r\n\r\nstruct Foo {\r\n  private_field  int // can only be accessed in the same module (default)\r\n  len-           int // read-only field that can be accessed from an outside module, but not modified\r\n  public_field+  int // public field that can be accessed and modified from outside\r\n}\r\n\r\n\r\nmodule main\r\n\r\nfn main() {\r\n  foo := new_foo()\r\n  foo.private_field // will not compile\r\n  println(foo.len) // OK\r\n  foo.len++ // will not compile\r\n  foo.public_field++ //OK\r\n}\r\n```\r\nWhat do you think?\r\n\r\n&nbsp;\r\n\r\n**edit**\r\n\r\nSlight improvement:\r\n\r\n```\r\nstruct Foo {\r\n    private_field int // can only be accessed in the same module (default)\r\n   -len           int // read-only field that can be accessed from an outside module, but not modified\r\n   +public_field  int // public field that can be accessed and modified from outside\r\n}\r\n```\r\n\r\n&nbsp;\r\n\r\n**edit 2**\r\n\r\nImmutable struct fields by default got a lot of support:\r\n\r\n```\r\nstruct Foo {\r\n    foo1     int // can only be accessed in the same module, but not modified (default)\r\n    foo2 mut int // can only be accessed and modified in the same module\r\n   +foo3     int // read-only field that can be accessed from an outside module, but not modified\r\n   +foo4 mut int // public field that can be accessed and modified from an outside module\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/vlang/v/issues/comments/487357148","html_url":"https://github.com/vlang/v/issues/64#issuecomment-487357148","issue_url":"https://api.github.com/repos/vlang/v/issues/64","id":487357148,"node_id":"MDEyOklzc3VlQ29tbWVudDQ4NzM1NzE0OA==","user":{"login":"whoizit","id":359276,"node_id":"MDQ6VXNlcjM1OTI3Ng==","avatar_url":"https://avatars1.githubusercontent.com/u/359276?v=4","gravatar_id":"","url":"https://api.github.com/users/whoizit","html_url":"https://github.com/whoizit","followers_url":"https://api.github.com/users/whoizit/followers","following_url":"https://api.github.com/users/whoizit/following{/other_user}","gists_url":"https://api.github.com/users/whoizit/gists{/gist_id}","starred_url":"https://api.github.com/users/whoizit/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/whoizit/subscriptions","organizations_url":"https://api.github.com/users/whoizit/orgs","repos_url":"https://api.github.com/users/whoizit/repos","events_url":"https://api.github.com/users/whoizit/events{/privacy}","received_events_url":"https://api.github.com/users/whoizit/received_events","type":"User","site_admin":false},"created_at":"2019-04-28T08:23:51Z","updated_at":"2019-04-28T08:23:51Z","author_association":"NONE","body":"if it is a `public mutable`, you should write `function` instead of `fn`. But then I will personally teach Rust, instead vlang.\r\nMaybe if you want to write \"readable\", then you should learn _TypeScript_ or something like that? This is exactly what you want https://www.typescriptlang.org/docs/handbook/classes.html"}}
{"actor":{"display_login":"whoizit"}}