anchor.diff:              setelement(RNum, Record, MergedMsg)
       end.
   
  -append_to_element(RNum, NewElem, Record)                                       ->
  +append_to_element(RNum, NewElem, Record) ->
       PrevElems = element(RNum, Record),
       setelement(RNum, Record, [NewElem | PrevElems]).
   
  -append_to_map(RNum, {Key, _Value}=NewItem, Record)                             ->
  +append_to_map(RNum, {Key, _Value}=NewItem, Record) ->
       PrevElems = element(RNum, Record),
       NewElems = lists:keystore(Key, 1, PrevElems, NewItem),
       setelement(RNum, Record, NewElems).
  
positive.code:              Msg, MsgDefs) ->
      encode_repeated(element(RNum, Msg), FNum, Type, MsgDefs, <<>>).
  
  encode_repeated([Elem | Rest], FNum, Type, MsgDefs, Acc)                       ->
      EncodedValue = encode_field_value(Elem, FNum, Type, MsgDefs),
      NewAcc = <<Acc/binary, EncodedValue/binary>>,
      encode_repeated(Rest, FNum, Type, MsgDefs, NewAcc);
  encode_repeated([], _FNum, _Type, _MsgDefs, Acc)                               ->
      Acc.
  
  encode_field_value(Value, FNum, Type, MsgDefs)                                 ->
      <<(encode_fnum_type(FNum, Type))/binary,
        (encode_value(Value, Type, MsgDefs))/binary>>.
  
  encode_fnum_type(FNum, Type)                                                   ->
      encode_varint((FNum bsl 3) bor encode_wiretype(Type)).
  
  encode_value(Value, Type, MsgDefs)                                             ->
      case Type of
          sint32 ->
              encode_varint(encode_zigzag(Value));
  
negative.code:             {{Key,Value}, Rest2}
          end.
  
  add_field(Value, FieldDef, false=_IsOneof, MsgDefs, Record) ->
      %% FIXME: what about bytes?? "For numeric types and strings, if
      %% the same value appears multiple times, the parser accepts the
      %% last value it sees." But what about bytes?
  