Skip to content

records vs maps #1

@vasu-dasari

Description

@vasu-dasari

Hi,

This is more of a question than an issue.

I see that GPB Messages are essentially structured records. But, the grpc generates erlang files (from proto files) which uses maps. Is there a way we can generate record format for messages?

The main advantage I can see is,

  1. I can include the generated header file in other Erlang modules and we have a handy way of generating messages.
  2. Also, if protobuf initializes some members of a message to default values, records could have been initialized to those default values as well, thereby caller need not worry filling in those fields. If it were maps, the caller needs to populate every possible member of message or else, I could get a runtime exception when invoking a service which is using that Message.
  3. I could take the help of an editor to populate record fields for auto-completing record names or field names. Thereby code is less prone to typos.

If I can generate a record with existing code, can you please point me to an example on how to do that?

Thanks
-Vasu

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions