title: How to define an optional field in protobuf 3
body: <p>I need to specify a message with an optional field in protobuf (proto3 syntax). In terms of proto 2 syntax, the message I want to express is something like:</p>
  
  <pre><code>message Foo {
      required int32 bar = 1;
      optional int32 baz = 2;
  }
  </code></pre>
  
  <p>From my understanding "optional" concept has been removed from syntax proto 3 (along with required concept). Though it is not clear the alternative - using the default value to state that a field has not been specified from the sender, leaves an ambiguity if the default value belongs to the valid values domain (consider for example a boolean type).</p>
  
  <p>So, how am I supposed to encode the message above? Thank you.</p>