title: Using protobuf enum value as a field number
body: <p>I'm wondering if it is possible to use Google Protocol Buffers' enum constants as a field number of other messages, like</p>
  
  <pre><code>enum Code {
    FOO = 100;
    BAR = 101;
  }
  
  message Message {
    required string foo = FOO;
  }
  </code></pre>
  
  <p>This code doesn't work because <code>FOO</code>'s type is <code>enum Code</code> and only a number can be used as a field number.</p>
  
  <p>I am trying to build polymorphic message definitions like this <a href="https://stackoverflow.com/a/8000409/425943">animal example</a>, that defines <code>Cat = 1;</code> in <code>enum Type</code> and <code>required Cat animal = 100;</code> as a unique extension number.</p>
  
  <p>I thought it'd be nice to do</p>
  
  <pre><code>message Message {
    required string foo = FOO.value;
  }
  </code></pre>
  
  <p>, so that I can ensure the uniqueness of the extension field number without introducing another magic number. </p>
  
  <p>So the question: is it possible to refer an enum's integer value in the protocol buffer language?</p>