anchor.diff:  append_to_element(RNum, NewElem, Record) ->
       PrevElems = element(RNum, Record),
       setelement(RNum, Record, [NewElem | PrevElems]).
  -
  -append_packed_to_element(RNum, NewElems, Record) ->
  -    PrevElems = element(RNum, Record),
  -    setelement(RNum, Record, lists:reverse(NewElems, PrevElems)).
   
   merge_msgs(PrevMsg, NewMsg, MsgDefs)
     when element(1,PrevMsg) == element(1,NewMsg) ->
  
positive.code:             setelement(RNum, Record, Value);
          #field{rnum = RNum, occurrence = optional}->
              setelement(RNum, Record, Value);
          #field{rnum = RNum, occurrence = repeated, opts=Opts} ->
              case proplists:get_bool(packed, Opts) of
                  true  -> append_packed_to_element(RNum, Value, Record);
                  false -> append_to_element(RNum, Value, Record)
              end
      end.
  
  merge_field(RNum, NewMsg, Record, MsgDefs) ->
  
negative.code:         false ->
              Rest2 = skip_field(Rest, WireType),
              decode_field(MsgDef, MsgDefs, Rest2, Msg);
          #field{type = FieldType, rnum=RNum, opts=Opts} = FieldDef ->
              case proplists:get_bool(packed, Opts) of
                  true ->
                      AccSeq = element(RNum, Msg),
                      {NewSeq, Rest2} = decode_packed(FieldType, Rest, MsgDefs,
                                                     AccSeq),
                      NewMsg = setelement(RNum, Msg, NewSeq),
                      decode_field(Rest2, MsgDef, MsgDefs, NewMsg);
                  false ->
                      {NewValue, Rest2} = decode_type(FieldType, Rest, MsgDefs),
                      NewMsg = add_field(NewValue, FieldDef, MsgDefs, Msg),
                      decode_field(Rest2, MsgDef, MsgDefs, NewMsg)
              end
      end;
  decode_field(<<>>, MsgDef, _MsgDefs, Record0) ->
      %% Reverse any repeated fields, but only on the top-level, not recursively.
  