{"action":"created","issue":{"url":"https://api.github.com/repos/google/protobuf/issues/1079","repository_url":"https://api.github.com/repos/google/protobuf","labels_url":"https://api.github.com/repos/google/protobuf/issues/1079/labels{/name}","comments_url":"https://api.github.com/repos/google/protobuf/issues/1079/comments","events_url":"https://api.github.com/repos/google/protobuf/issues/1079/events","html_url":"https://github.com/google/protobuf/issues/1079","id":124293617,"number":1079,"title":"[feature request] scoped enums with an option","user":{"login":"goldenbull","id":9129006,"avatar_url":"https://avatars.githubusercontent.com/u/9129006?v=3","gravatar_id":"","url":"https://api.github.com/users/goldenbull","html_url":"https://github.com/goldenbull","followers_url":"https://api.github.com/users/goldenbull/followers","following_url":"https://api.github.com/users/goldenbull/following{/other_user}","gists_url":"https://api.github.com/users/goldenbull/gists{/gist_id}","starred_url":"https://api.github.com/users/goldenbull/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goldenbull/subscriptions","organizations_url":"https://api.github.com/users/goldenbull/orgs","repos_url":"https://api.github.com/users/goldenbull/repos","events_url":"https://api.github.com/users/goldenbull/events{/privacy}","received_events_url":"https://api.github.com/users/goldenbull/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/google/protobuf/labels/c++","name":"c++","color":"5319e7"},{"url":"https://api.github.com/repos/google/protobuf/labels/enhancement","name":"enhancement","color":"84b6eb"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":21,"created_at":"2015-12-30T02:08:24Z","updated_at":"2016-03-17T12:55:41Z","closed_at":null,"body":"Currently pb3 applies c98 enum scoping rule for enums. This is inconvenient when we need same Identifier in different enums. I hope there will be an new option for enums as follow:\r\n```\r\nenum Status {\r\n  option scoped = true;\r\n  START = 0;\r\n  STOP = 1;\r\n  PAUSE = 2;\r\n}\r\n\r\nenum Action {\r\n  option scoped = true;\r\n  NOP = 0;\r\n  START = 1; // note this entry has a different value from Status::START\r\n  STOP = 2;\r\n}\r\n```\r\n\r\nWith the annotation ```option scoped = true``` the compiler can use ```enum class``` for C++11, providing better code, and we users will feel more comfortable to use proper identifiers for enums. And this is totally compatible with current implementation, all existing code will not be disturbed."},"comment":{"url":"https://api.github.com/repos/google/protobuf/issues/comments/197867105","html_url":"https://github.com/google/protobuf/issues/1079#issuecomment-197867105","issue_url":"https://api.github.com/repos/google/protobuf/issues/1079","id":197867105,"user":{"login":"goldenbull","id":9129006,"avatar_url":"https://avatars.githubusercontent.com/u/9129006?v=3","gravatar_id":"","url":"https://api.github.com/users/goldenbull","html_url":"https://github.com/goldenbull","followers_url":"https://api.github.com/users/goldenbull/followers","following_url":"https://api.github.com/users/goldenbull/following{/other_user}","gists_url":"https://api.github.com/users/goldenbull/gists{/gist_id}","starred_url":"https://api.github.com/users/goldenbull/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/goldenbull/subscriptions","organizations_url":"https://api.github.com/users/goldenbull/orgs","repos_url":"https://api.github.com/users/goldenbull/repos","events_url":"https://api.github.com/users/goldenbull/events{/privacy}","received_events_url":"https://api.github.com/users/goldenbull/received_events","type":"User","site_admin":false},"created_at":"2016-03-17T12:55:41Z","updated_at":"2016-03-17T12:55:41Z","body":"In most cases `auto_strip_enum_prefixes` is enough, however `scoped_alias` can provide even stronger ability, for example, to define an enum member in Chinese characters. Maybe this sounds over-design, but in the projects I'm working on, it's really useful to have Chinese name for each enum member. But seems proto file is ASCII encoded only, so maybe it's impossible to have UTF8 identifiers."}}