{"action":"created","issue":{"url":"https://api.github.com/repos/apple/swift-protobuf/issues/47","repository_url":"https://api.github.com/repos/apple/swift-protobuf","labels_url":"https://api.github.com/repos/apple/swift-protobuf/issues/47/labels{/name}","comments_url":"https://api.github.com/repos/apple/swift-protobuf/issues/47/comments","events_url":"https://api.github.com/repos/apple/swift-protobuf/issues/47/events","html_url":"https://github.com/apple/swift-protobuf/issues/47","id":181154648,"number":47,"title":"Dealing with optionals/collisions with real values","user":{"login":"vCrespoP","id":7558064,"avatar_url":"https://avatars.githubusercontent.com/u/7558064?v=3","gravatar_id":"","url":"https://api.github.com/users/vCrespoP","html_url":"https://github.com/vCrespoP","followers_url":"https://api.github.com/users/vCrespoP/followers","following_url":"https://api.github.com/users/vCrespoP/following{/other_user}","gists_url":"https://api.github.com/users/vCrespoP/gists{/gist_id}","starred_url":"https://api.github.com/users/vCrespoP/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/vCrespoP/subscriptions","organizations_url":"https://api.github.com/users/vCrespoP/orgs","repos_url":"https://api.github.com/users/vCrespoP/repos","events_url":"https://api.github.com/users/vCrespoP/events{/privacy}","received_events_url":"https://api.github.com/users/vCrespoP/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2016-10-05T13:30:58Z","updated_at":"2016-10-05T14:18:06Z","closed_at":null,"body":"Hello once again :)\r\n\r\nI'm testing out protoBuf (v.3) and now optionals have been dropped. How do you suggest dealing with them when the default value collides with a possible real value?\r\n\r\nFor instance:\r\nUser has to input an amount of 0, which is different from not having set the field at all.\r\n\r\n- Is there any mechanism built inside this framework/protocol buffers that allows something similar?\r\n- Is the protoBuf definition limiting this _need_?\r\n- Should that be handled from the UI/models knowing if the user enters a default value then we should actually have nothing? (Seems not really right, and Swift and optionals would personally be the way to go)\r\n- Anything else?\r\n\r\nThanks a lot."},"comment":{"url":"https://api.github.com/repos/apple/swift-protobuf/issues/comments/251688021","html_url":"https://github.com/apple/swift-protobuf/issues/47#issuecomment-251688021","issue_url":"https://api.github.com/repos/apple/swift-protobuf/issues/47","id":251688021,"user":{"login":"thomasvl","id":5279928,"avatar_url":"https://avatars.githubusercontent.com/u/5279928?v=3","gravatar_id":"","url":"https://api.github.com/users/thomasvl","html_url":"https://github.com/thomasvl","followers_url":"https://api.github.com/users/thomasvl/followers","following_url":"https://api.github.com/users/thomasvl/following{/other_user}","gists_url":"https://api.github.com/users/thomasvl/gists{/gist_id}","starred_url":"https://api.github.com/users/thomasvl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/thomasvl/subscriptions","organizations_url":"https://api.github.com/users/thomasvl/orgs","repos_url":"https://api.github.com/users/thomasvl/repos","events_url":"https://api.github.com/users/thomasvl/events{/privacy}","received_events_url":"https://api.github.com/users/thomasvl/received_events","type":"User","site_admin":false},"created_at":"2016-10-05T14:18:05Z","updated_at":"2016-10-05T14:18:05Z","body":"By _v.3_ I'm assuming you mean protobuf syntax _proto3_?  Both proto2 and proto3 syntax are supported and usable.  As the [protobuf overview](https://developers.google.com/protocol-buffers/docs/overview) mentions, both syntaxes are supported, so you you don't want the proto3 behaviors around zeros, you can use proto2.\r\n\r\nIf you do want to use proto3 syntax, there are a few options to deal with explicit zero values:\r\n* You can out the field in a `oneof`, it will then property to tell which item in the oneof is set (or if\r\n   non are).  That can then signal is the value is set to zero.\r\n\r\n   ```protobuf\r\n   message MyMsg {\r\n     oneof has_value {\r\n        int32 value = 1;\r\n     }\r\n   }\r\n   ```\r\n* You can use the [wrappers](https://github.com/google/protobuf/blob/master/src/google/protobuf/wrappers.proto) Well Known Types.  By putting it in a message, it does nest it on the wire (in binary and JSON), but that provides a message that can be tested to see if it is present before accessing the value.\r\n\r\nFYI - As mentioned on the [protobuf support page](https://developers.google.com/protocol-buffers/docs/faq), there is a [forum \\(Google group\\)](https://groups.google.com/forum/#!forum/protobuf) for general protobuf questions.  Most of what you are asking here isn't really specific to Swift and is generally about protocol buffers.\r\n\r\nOne last comment - The Swift library is still very young, so some of the what fields get exposed may well end up changing as we finish working out the best interfaces.  But the method mentioned above is generally how'd you'd capture this sorta information.\r\n"}}
{"actor":{"display_login":"thomasvl"}}